mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
Fix day number calculation taking DST into account
Based on the SO answer http://stackoverflow.com/a/15289883/974487
This commit is contained in:
parent
002ac8ca4c
commit
067ae77ad9
1 changed files with 4 additions and 2 deletions
|
|
@ -595,8 +595,10 @@
|
|||
else
|
||||
weekday--;
|
||||
}
|
||||
var firstDayOfYear = new Date(date.getFullYear(), 0, 1),
|
||||
yday = (date - firstDayOfYear) / 86400000,
|
||||
|
||||
var firstDayOfYearUtc = Date.UTC(date.getFullYear(), 0, 1),
|
||||
dateUtc = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),
|
||||
yday = Math.floor((dateUtc - firstDayOfYearUtc) / 86400000),
|
||||
weekNum = (yday + 7 - weekday) / 7;
|
||||
|
||||
return Math.floor(weekNum);
|
||||
|
|
|
|||
Loading…
Reference in a new issue