Skip to content

Commit

Permalink
[bugfix] Fix moment#4698: Use ISO WeekYear for HTML5_FMT.WEEK
Browse files Browse the repository at this point in the history
  • Loading branch information
ashsearle committed Jul 13, 2018
1 parent 2e2a5b3 commit 10a98e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/moment.js
Expand Up @@ -88,7 +88,7 @@ moment.HTML5_FMT = {
TIME: 'HH:mm', // <input type="time" />
TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" />
TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" />
WEEK: 'YYYY-[W]WW', // <input type="week" />
WEEK: 'GGGG-[W]WW', // <input type="week" />
MONTH: 'YYYY-MM' // <input type="month" />
};

Expand Down
14 changes: 7 additions & 7 deletions src/test/moment/format.js
Expand Up @@ -5,16 +5,16 @@ import moment from '../../moment';
module('format');

test('format using constants', function (assert) {
var m = moment('2017-09-01T23:40:40.678');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL), '2017-09-01T23:40', 'datetime local format constant');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS), '2017-09-01T23:40:40', 'datetime local format constant');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL_MS), '2017-09-01T23:40:40.678', 'datetime local format constant with seconds and millis');
assert.equal(m.format(moment.HTML5_FMT.DATE), '2017-09-01', 'date format constant');
var m = moment('2016-01-02T23:40:40.678');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL), '2016-01-02T23:40', 'datetime local format constant');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS), '2016-01-02T23:40:40', 'datetime local format constant');
assert.equal(m.format(moment.HTML5_FMT.DATETIME_LOCAL_MS), '2016-01-02T23:40:40.678', 'datetime local format constant with seconds and millis');
assert.equal(m.format(moment.HTML5_FMT.DATE), '2016-01-02', 'date format constant');
assert.equal(m.format(moment.HTML5_FMT.TIME), '23:40', 'time format constant');
assert.equal(m.format(moment.HTML5_FMT.TIME_SECONDS), '23:40:40', 'time format constant with seconds');
assert.equal(m.format(moment.HTML5_FMT.TIME_MS), '23:40:40.678', 'time format constant with seconds and millis');
assert.equal(m.format(moment.HTML5_FMT.WEEK), '2017-W35', 'week format constant');
assert.equal(m.format(moment.HTML5_FMT.MONTH), '2017-09', 'month format constant');
assert.equal(m.format(moment.HTML5_FMT.WEEK), '2015-W53', 'week format constant');
assert.equal(m.format(moment.HTML5_FMT.MONTH), '2016-01', 'month format constant');
});

test('format YY', function (assert) {
Expand Down

0 comments on commit 10a98e3

Please sign in to comment.