mirror of
https://github.com/idanoo/go-mastodon-stats
synced 2025-07-02 22:32:19 +00:00
Make sure we don't get todays values
This commit is contained in:
parent
5a073e5232
commit
31ad65d711
2 changed files with 21 additions and 0 deletions
|
@ -22,6 +22,7 @@ func getStartofDayMonday() time.Time {
|
||||||
}
|
}
|
||||||
// Iterate until Monday!
|
// Iterate until Monday!
|
||||||
t := time.Now().In(localTime)
|
t := time.Now().In(localTime)
|
||||||
|
t = t.AddDate(0, 0, -1)
|
||||||
for t.Weekday() != time.Monday {
|
for t.Weekday() != time.Monday {
|
||||||
t = t.AddDate(0, 0, -1)
|
t = t.AddDate(0, 0, -1)
|
||||||
}
|
}
|
||||||
|
|
20
test.go
Normal file
20
test.go
Normal file
|
@ -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()))
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue