fix TimeWeekX inconsistencies & limit MezFes duration

This commit is contained in:
wish
2023-11-26 19:21:31 +11:00
parent b3af01b803
commit a0fbfc248b
5 changed files with 11 additions and 5 deletions

View File

@@ -16,8 +16,11 @@ func TimeMidnight() time.Time {
func TimeWeekStart() time.Time {
midnight := TimeMidnight()
offset := (int(midnight.Weekday()) - 1) * -24
return midnight.Add(time.Hour * time.Duration(offset))
offset := int(midnight.Weekday()) - int(time.Monday)
if offset < 0 {
offset += 7
}
return midnight.Add(-time.Duration(offset) * 24 * time.Hour)
}
func TimeWeekNext() time.Time {