fix(package): [datetime] use local zone for zero hour timestamps (#415)

* fix(package): [datetime] use local zone for zero hour timestamps

* test(package): [datetime] cover zero hour timestamps in other zones
This commit is contained in:
Lee Sang Gyu authored and GitHub committed 2026-11-09 17:37:13 +08:00
1 parent b09d6af4a4
commit 5839ab33a9
2 files changed
+27 -4

No files matched your search

+2 -4
View File
@@ -188,15 +188,13 @@ func GetTodayEndTime() string {
// GetZeroHourTimestamp return timestamp of zero hour (timestamp of 00:00).
// Play: https://go.dev/play/p/QmL2oIaGE3q
func GetZeroHourTimestamp() int64 {
ts := time.Now().Format("2006-01-02")
t, _ := time.Parse("2006-01-02", ts)
return t.UTC().Unix() - 8*3600
return BeginOfDay(time.Now()).Unix()
}
// GetNightTimestamp return timestamp of zero hour (timestamp of 23:59).
// Play: https://go.dev/play/p/UolysR3MYP1
func GetNightTimestamp() int64 {
return GetZeroHourTimestamp() + 86400 - 1
return EndOfDay(time.Now()).Unix()
}
// FormatTimeToStr convert time to string.