calendar

package
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package domain defines the main constructs for managing daily work schedules.

Package calendar provides functionality related to managing days and time segments within those days.

A person is the entity for which we associate their Calendars, Working days, Holidays and preferred working hours.

Index

Constants

View Source
const (
	// WorkDay indicates a day where work activities occur.
	WorkDay = iota

	// NonWorkingDay indicates a day free from work activities.
	NonWorkingDay
)

Variables

This section is empty.

Functions

func FreeTime

func FreeTime()

func PrintOpenSlots

func PrintOpenSlots(slots []OpenSlot)

PrintOpenSlots prints the open slots for a given day.

Types

type Attendee

type Attendee struct {
	Type         string       `json:"type"`
	EmailAddress EmailAddress `json:"emailAddress"`
}

type AttendeeAvailability

type AttendeeAvailability struct {
	Attendee     Attendee `json:"attendee"`
	Availability string   `json:"availability"`
}

type DateTimeTimeZone

type DateTimeTimeZone struct {
	DateTime string `json:"dateTime"`
	TimeZone string `json:"timeZone"`
}

type Day

type Day struct {
	ID uuid.UUID

	// Date specifies the calendar date for the work day, excluding the time details.
	Date time.Time

	// Start marks the beginning of the work day.
	Start time.Time

	// End signifies the conclusion of the work day.
	End time.Time

	// Segments represents chunks of time within the day. These can be continuous or
	// can overlap (e.g., due to double bookings). A day may also have no segments.
	Segments []Segment
}

Day represents a specific date where work activities might take place. It includes details like start and end times of work, and is influenced by factors such as a person's calendar entries, public holidays, and preferred working hours.

TODO: Updating the start or end time of a day may invalidate existing segments.

func (*Day) AddSegment

func (d *Day) AddSegment(s Segment) error

AddSegment attaches a new time segment to the current day.

func (*Day) ClearSegments

func (d *Day) ClearSegments()

ClearSegments removes all segments from the day.

func (*Day) RemoveSegment

func (d *Day) RemoveSegment(s Segment)

RemoveSegment removes a segment from the day.

func (*Day) UpdateSegment

func (d *Day) UpdateSegment(s Segment) error

UpdateSegment updates a segment in the day.

type EmailAddress

type EmailAddress struct {
	Address string `json:"address"`
	Name    string `json:"name"`
}

type ErrDayAlreadyExists

type ErrDayAlreadyExists struct {
	Date time.Time
}

ErrDayAlreadyExists indicates that a day already exists for a specific date.

func (ErrDayAlreadyExists) Error

func (e ErrDayAlreadyExists) Error() string

Error returns a string representation of ErrDayAlreadyExists.

type ErrDayNotFound

type ErrDayNotFound struct {
	Date time.Time
}

ErrDayNotFound indicates that a day was not found for a specific date.

func (ErrDayNotFound) Error

func (e ErrDayNotFound) Error() string

Error returns a string representation of ErrDayNotFound.

type ErrInvalidSegmentRange

type ErrInvalidSegmentRange struct {
	Start time.Time
	End   time.Time
}

ErrInvalidSegmentRange indicates that the start and end times of a segment are not valid. For example, when the start time is after the end time.

func (ErrInvalidSegmentRange) Error

func (e ErrInvalidSegmentRange) Error() string

Error returns a string representation of ErrInvalidSegmentRange. It checks if the start time is after the end time, if so, it provides an appropriate error message. Otherwise, it indicates a generic invalid range error.

type ErrSegmentOutsideOfDay

type ErrSegmentOutsideOfDay struct {
	Segment *Segment
	Day     *Day
}

ErrSegmentOutsideOfDay indicates that a time segment is outside the boundaries of a day. This error is used when trying to associate a segment with a day and the segment's time range does not fit within the day's time range.

func (ErrSegmentOutsideOfDay) Error

func (e ErrSegmentOutsideOfDay) Error() string

Error checks which part of the segment is outside of the day's boundaries and returns the appropriate error message.

type Expansion

type Expansion struct {
	NumberOfTimeSuggestions              int               `json:"numberOfTimeSuggestions"`
	MaximumNonWorkHoursSuggestionsPerDay int               `json:"maximumNonWorkHoursSuggestionsPerDay"`
	MaximumSuggestionsPerDay             int               `json:"maximumSuggestionsPerDay"`
	MinimumSuggestionQuality             SuggestionQuality `json:"minimumSuggestionQuality"`
}

type ExternalID added in v0.0.19

type ExternalID struct {
	ID   string
	Type string
}

type FindMeetingTimesRequest

type FindMeetingTimesRequest struct {
	Attendees      []Attendee     `json:"attendees"`
	TimeConstraint TimeConstraint `json:"timeConstraint"`
	//LocationConstraint               LocationConstraint `json:"locationConstraint"`
	IsOrganizerOptional bool `json:"isOrganizerOptional"`
	//SuggestedTimeSuggestionExpansion Expansion          `json:"suggestedTimeSuggestionExpansion"`
	MaxCandidates             int    `json:"maxCandidates"`
	MeetingDuration           string `json:"meetingDuration"`
	ReturnSuggestionReasons   bool   `json:"returnSuggestionReasons"`
	MinimumAttendeePercentage int    `json:"minimumAttendeePercentage"`
}

type FindMeetingTimesResponse

type FindMeetingTimesResponse struct {
	MeetingTimeSuggestions []MeetingTimeSuggestion `json:"meetingTimeSuggestions"`
	EmptySuggestionsReason string                  `json:"emptySuggestionsReason"`
}

type MeResponse

type MeResponse struct {
	DisplayName       string   `json:"displayName"`
	Mail              string   `json:"mail"`
	UserPrincipalName string   `json:"userPrincipalName"`
	MobilePhone       string   `json:"mobilePhone"`
	BusinessPhones    []string `json:"businessPhones"`
}

type MeetingTimeSuggestion

type MeetingTimeSuggestion struct {
	Confidence            float32                `json:"confidence"`
	OrganizerAvailability string                 `json:"organizerAvailability"`
	SuggestionReason      string                 `json:"suggestionReason"`
	AttendeeAvailability  []AttendeeAvailability `json:"attendeeAvailability"`
	MeetingTimeSlot       TimeSlot               `json:"meetingTimeSlot"`
}

type OpenSlot

type OpenSlot struct {
	Start time.Time
	End   time.Time
}

func FindOpenSlots

func FindOpenSlots(day *Day) []OpenSlot

type Person

type Person struct {
	ID    uuid.UUID
	Name  string
	Email string

	// This is the ID of the person in the external system (e.g. Google, Azure AD).
	ExternalIDs []ExternalID

	// This is a flag to indicate if this is the person who is currently logged in.
	IsSignedOnUser bool

	// Collection of days associated with this person.
	Days []Day
}

func (*Person) AddDay

func (p *Person) AddDay(date time.Time) (*Day, error)

Factory method to create a new day for a person The following rules apply: - The day must not already exist for the person. - Only the date is used to create the day. - The start and end times are set to the default values. - The day is initialised with no segments.

func (*Person) RemoveDay

func (p *Person) RemoveDay(date time.Time) error

RemoveDay removes the day from the person. The following rules apply: - The day must exist for the person.

type Segment

type Segment struct {
	ID uuid.UUID

	// Description offers more details about the segment's nature.
	Description string

	// Start indicates when the segment begins, and it should fall within the encompassing day's duration.
	Start time.Time

	// End indicates when the segment concludes, and it should also stay within the day's limits.
	End time.Time

	// IsWorkingTime denotes whether the segment represents productive work time or a break.
	IsWorkingTime bool
}

Segment defines a time interval within a day, representing either working or non-working hours.

func NewSegment

func NewSegment(description string, start time.Time, end time.Time, isWorkingTime bool) Segment

factory method for creating a new segment

type SuggestionQuality

type SuggestionQuality struct {
	AttendeeConflict string `json:"attendeeConflict"`
	Unknown          string `json:"unknown"`
}

type TimeConstraint

type TimeConstraint struct {
	Timeslots []TimeSlot `json:"timeslots"`
}

type TimeSlot

type TimeSlot struct {
	Start DateTimeTimeZone `json:"start"`
	End   DateTimeTimeZone `json:"end"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL