mirror of
https://github.com/idanoo/go-mastodon-stats
synced 2025-07-01 05:42:19 +00:00
31 lines
657 B
Go
31 lines
657 B
Go
package gomastodonstats
|
|
|
|
import (
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func getStartofDay() time.Time {
|
|
localTime, err := time.LoadLocation(TIMEZONE)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
t := time.Now().In(localTime)
|
|
year, month, day := t.Date()
|
|
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
|
|
}
|
|
|
|
func getStartofDayMonday() time.Time {
|
|
localTime, err := time.LoadLocation(TIMEZONE)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
// 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)
|
|
}
|
|
year, month, day := t.Date()
|
|
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
|
|
}
|