fix now() InLocation(local), deadline per-one

This commit is contained in:
bel
2025-05-17 21:24:32 -06:00
parent 75b7e21bec
commit fe02d1624f
3 changed files with 10 additions and 6 deletions

View File

@@ -14,7 +14,7 @@ func Next(ctx context.Context) (time.Time, error) {
}
if deadline := Deadline(); time.Since(deadline) > time.Minute {
return time.Parse("2006-01-02", time.Now().Add(24*time.Hour).Format("2006-01-02"))
return midnightLastNight().Add(24 * time.Hour), nil
}
type Did struct {

View File

@@ -3,9 +3,13 @@ package asses
import "time"
func Deadline() time.Time {
midnightLastNight, err := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
return midnightLastNight().Add(8 * time.Hour) // midnight-8AM
}
func midnightLastNight() time.Time {
t, err := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
if err != nil {
panic(err)
}
return midnightLastNight.Add(8 * time.Hour) // midnight-8AM
return t
}