Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #56 (Bug in %U) #59

Merged
merged 1 commit into from Mar 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions strftime.js
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions test.js
Expand Up @@ -115,6 +115,9 @@ assert.format('%z', null, '+0000');
assert.format('%:z', null, '+00:00');
assert.format('%%', '%'); // any other char
assert.format('%F %T', null, '1970-01-01 00:00:00', new Date(0));
assert.format('%U', '13', "12", (new Date('03-26-2017 00:00:00')));
assert.format('%U', '13', null, (new Date('03-27-2017 00:00:00')));
assert.format('%U', '14', "13", (new Date('04-02-2017 00:00:00')));
ok('GMT');


Expand Down