fix(package): [datetime] count calendar days across DST (#385)

This commit is contained in:
Yusuf Efe authored and GitHub committed 2026-10-22 10:48:53 +08:00
1 parent 5c04ffae97
commit 752f1ed63d
2 files changed
+21 -5

No files matched your search

+1 -5
View File
@@ -343,11 +343,7 @@ func BetweenSeconds(t1 time.Time, t2 time.Time) int64 {
// DayOfYear returns which day of the year the parameter date `t` is.
// Play: https://go.dev/play/p/0hjqhTwFNlH
func DayOfYear(t time.Time) int {
y, m, d := t.Date()
firstDay := time.Date(y, 1, 1, 0, 0, 0, 0, t.Location())
nowDate := time.Date(y, m, d, 0, 0, 0, 0, t.Location())
return int(nowDate.Sub(firstDay).Hours() / 24)
return t.YearDay() - 1
}
// IsWeekend checks if passed time is weekend or not.