Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion models/schedule_tabulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func straddlesDay(s *ScheduleItem) bool {
return straddle
}

func listStraddlesDay(s *ScheduleItem) bool {
dayBoundary := 0
adjustedStart := s.Start.Add(time.Hour * time.Duration(-dayBoundary))
adjustedEnd := s.Finish.Add(time.Hour * time.Duration(-dayBoundary))
Comment on lines +58 to +60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit confused by this - why is there a variable that's always 0, and why are we adding zero hours to the start/finish time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the function from above and modified it badly. I can fix it if needed. Tbh I might rewrite the schedule, the code for it is a mess

straddle := adjustedEnd.Day() != adjustedStart.Day() && s.Finish.Sub(s.Start) > time.Hour
return straddle
}

// calcScheduleBoundaries gets the offsets of the earliest and latest visible schedule hours.
// It returns these as top and bot respectively.
func calcScheduleBoundaries(items []*ScheduleItem, scheduleStart time.Time) (top, bot utils.StartOffset, err error) {
Expand Down Expand Up @@ -350,7 +358,7 @@ func buildList(schedule []*ScheduleItem, dates []time.Time) []WeekScheduleList {
}
for _, item := range schedule {
dayIndex := (item.Start.Weekday() + 6) % 7
if straddlesDay(item) {
if listStraddlesDay(item) {
item.ShowWeekDay = true
EnddayIndex := (item.Finish.Weekday() + 6) % 7
for i := dayIndex; i<=EnddayIndex; i++ {
Expand Down