diff --git a/internal/gomastodonstats/utils.go b/internal/gomastodonstats/utils.go index 74fd8d1..85576c4 100644 --- a/internal/gomastodonstats/utils.go +++ b/internal/gomastodonstats/utils.go @@ -22,6 +22,7 @@ func getStartofDayMonday() time.Time { } // Iterate until Monday! t := time.Now().In(localTime) + t = t.AddDate(0, 0, -1) for t.Weekday() != time.Monday { t = t.AddDate(0, 0, -1) } diff --git a/test.go b/test.go new file mode 100644 index 0000000..a451184 --- /dev/null +++ b/test.go @@ -0,0 +1,20 @@ +package main + +import ( + "log" + "time" +) + +func main() { + localTime, err := time.LoadLocation("Pacific/Auckland") + if err != nil { + log.Fatal(err) + } + // Iterate until Monday! + t := time.Now().In(localTime) + for t.Weekday() != time.Monday { + t = t.AddDate(0, 0, -1) + } + year, month, day := t.Date() + log.Println(time.Date(year, month, day, 0, 0, 0, 0, t.Location())) +}