Documentation
¶
Index ¶
- Variables
- type Schedule
- func (s Schedule) AvailableMinutes(day time.Time) int
- func (s Schedule) Contains(t time.Time) bool
- func (s Schedule) MatchesDay(t time.Time) bool
- func (s Schedule) MatchesTime(t time.Time) bool
- func (s Schedule) NextMatchingDay(from time.Time) time.Time
- func (s Schedule) NextNonMatchingDay(from time.Time) time.Time
- func (s Schedule) PrevMatchingDay(from time.Time) time.Time
- func (s Schedule) PrevNonMatchingDay(from time.Time) time.Time
- func (s Schedule) SlotsForDay(day time.Time) []TimeSlot
- func (s Schedule) SlotsForRange(from, to time.Time) []TimeSlot
- type TimeRange
- type TimeSlot
Constants ¶
This section is empty.
Variables ¶
var DefaultWorkingHoursSchedule = Schedule{ Days: []time.Weekday{time.Monday, time.Tuesday, time.Wednesday, time.Thursday, time.Friday}, StartHour: 9, EndHour: 17, }
DefaultWorkingHoursSchedule is a standard Monday-Friday 9-17 working hours schedule.
Functions ¶
This section is empty.
Types ¶
type Schedule ¶
type Schedule struct {
Days []time.Weekday // e.g., [Mon, Tue, Wed, Thu, Fri]
StartHour int // e.g., 9
EndHour int // e.g., 17
Gaps []TimeRange // optional gaps (e.g., lunch: [{12, 13}])
Location *time.Location // timezone
}
Schedule defines working hours for a set of days.
func (Schedule) AvailableMinutes ¶
AvailableMinutes returns total available minutes in schedule for a day.
func (Schedule) Contains ¶
Contains returns true if t matches both the day and time of the schedule.
func (Schedule) MatchesDay ¶
MatchesDay returns true if t's weekday is one of the schedule's days.
func (Schedule) MatchesTime ¶
MatchesTime returns true if t's time-of-day is within schedule hours (excluding gaps).
func (Schedule) NextMatchingDay ¶
NextMatchingDay finds the next day matching the schedule.
func (Schedule) NextNonMatchingDay ¶
NextNonMatchingDay finds the next day not matching the schedule.
func (Schedule) PrevMatchingDay ¶
PrevMatchingDay finds the previous day matching the schedule. e.g., called on Sunday -> returns Friday (for Mon-Fri schedule).
func (Schedule) PrevNonMatchingDay ¶
PrevNonMatchingDay finds the previous day not matching the schedule. e.g., called on Monday -> returns Sunday (for Mon-Fri schedule).
func (Schedule) SlotsForDay ¶
SlotsForDay generates hour slots for a single day If gaps are configured, returns multiple slots (split by gaps).