Skip to content

Upgrade d3 time format to expose new formatting options for weekdays, weeks and quarters #5026

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

Merged
merged 6 commits into from
Jul 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/jasmine/tests/lib_date_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,19 @@ describe('dates', function() {
],
[
'%B \'%y WOY:%U DOW:%w',
'August \'12 WOY:32 DOW:1',
'August \'12 WOY:33 DOW:1',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed bug reported in d3/d3-time-format#62.

'Mesori \'28 WOY:## DOW:##' // world-cals doesn't support U or w
],
[
'%B \'%y QOY:%q WOY:%W DOW:%u',
'August \'12 QOY:3 WOY:33 DOW:1',
'Mesori \'28 QOY:3 WOY:48 DOW:1'
],
[
'%c && %x && .%2f .%f', // %<n>f is our addition
'Mon Aug 13 06:19:34 2012 && 08/13/2012 && .57 .5678',
'Pes Meso 7 06:19:34 1728 && 12/07/1728 && .57 .5678'
'8/13/2012, 6:19:34 AM && 8/13/2012 && .57 .5678',
'Pes Meso 7 6:19:34 AM 1728 && 12/07/1728 && .57 .5678'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/d3/d3/blob/master/CHANGES.md#time-formats-d3-time-format
The default U.S. English locale now uses 12-hour time and a more concise representation of the date. This aligns with local convention and is consistent with date.toLocaleString in Chrome, Firefox and Node

var now = new Date;
d3.timeFormat("%c")(new Date); // "6/23/2016, 2:01:33 PM"
d3.timeFormat("%x")(new Date); // "6/23/2016"
d3.timeFormat("%X")(new Date); // "2:01:38 PM"

]

].forEach(function(v) {
var fmt = v[0];
var expectedGregorian = v[1];
Expand Down