1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: critical infinite loop at the date of switch to daylight saving time

This commit is contained in:
Ferdinand Mütsch 2022-01-02 13:17:30 +01:00
parent 6f9015d3d8
commit fd6c36832e
2 changed files with 4 additions and 4 deletions

View File

@ -292,9 +292,9 @@ func generateDays(from, to time.Time) []time.Time {
days := make([]time.Time, 0)
from = utils.StartOfDay(from)
to = utils.StartOfDay(to.Add(24 * time.Hour))
to = utils.StartOfDay(to.AddDate(0, 0, 1))
for d := from; d.Before(to); d = d.Add(24 * time.Hour) {
for d := from; d.Before(to); d = d.AddDate(0, 0, 1) {
days = append(days, d)
}

View File

@ -66,7 +66,7 @@ func CeilDate(date time.Time) time.Time {
if floored == date {
return floored
}
return floored.Add(24 * time.Hour)
return floored.AddDate(0, 0, 1)
}
// SetLocation resets the time zone information of a date without converting it, i.e. 19:00 UTC will result in 19:00 CET, for instance
@ -88,7 +88,7 @@ func SplitRangeByDays(from time.Time, to time.Time) [][]time.Time {
intervals := make([][]time.Time, 0)
for t1 := from; t1.Before(to); {
t2 := StartOfDay(t1).Add(24 * time.Hour)
t2 := StartOfDay(t1).AddDate(0, 0, 1)
if t2.After(to) {
t2 = to
}