mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [datetime] count calendar days across DST (#385)
This commit is contained in:
1 parent
5c04ffae97
commit
752f1ed63d
2 files changed
+21
-5
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user