Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Update dateformatter.js #375

Merged
merged 2 commits into from
Jan 10, 2014
Merged

Update dateformatter.js #375

merged 2 commits into from
Jan 10, 2014

Conversation

cyberwombat
Copy link
Contributor

Corrected date calculation for day of week.

it looks like getDay() returns 0-6 but that 0 is sunday. So no modifier is necessary for the other weekdays - we just need sunday to become 7.

Both of these print 7 right now

{{ '28 Dec 2013'|date('N') }}
{{ '29 Dec 2013'|date('N') }}

Corrected date calculation for day of week
@paularmstrong
Copy link
Owner

Please ensure tests are passing.

This matches PHP:
echo date('N', strtotime('2011-09-06T16:05:02.000Z'))."\n";
echo date('N', strtotime('2011-09-04T16:05:02.000Z'))."\n";
@cyberwombat
Copy link
Contributor Author

Tests were failing but were wrong. Fixed test and added another for Sunday. See php code in commit message as I used that to check.

paularmstrong added a commit that referenced this pull request Jan 10, 2014
Fix date formatting for 'N' (ISO-8601 numeric representation of the day of the week)
@paularmstrong paularmstrong merged commit d70b853 into paularmstrong:master Jan 10, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants