Only report to mastodon Mondays

This commit is contained in:
idanoo 2023-02-12 14:20:17 +13:00
parent 003efe910e
commit 533cde2eaf
Signed by: idanoo
GPG key ID: 387387CDBC02F132
4 changed files with 74 additions and 29 deletions

View file

@ -14,3 +14,17 @@ func getStartofDay() time.Time {
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)
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())
}