Skip to content

Commit 8c97022

Browse files
committed
Fixed messageFormat dependency omission and a timezone-dependent test
1 parent d22ccb5 commit 8c97022

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

lib/compile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ DEPENDENCIES_VARS = {
5454
dateParserFn: true
5555
},
5656
messageFormatter: {
57+
messageFormat: true,
5758
messageFormatterFn: true
5859
},
5960
numberFormatter: {

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/functional/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ describe("The compiled `basic.js`", function() {
3636
});
3737

3838
it("should include support for dateParser", function() {
39-
var result = Globalize.dateParser({skeleton: "MMMd", timeZone: "America/New_York"})("Jan 1");
40-
expect(result.getMonth()).to.equal(0);
41-
expect(result.getDate()).to.equal(1);
39+
// When it is Feb 23 in New York, it has already been Feb 23rd in GMT for 4 or 5 hours (depending on DST).
40+
var inNewYorkTime = Globalize.dateParser({skeleton: "MMMd", timeZone: "America/New_York"})("Feb 23");
41+
expect(inNewYorkTime.getUTCMonth()).to.equal(1);
42+
expect(inNewYorkTime.getUTCDate()).to.equal(23);
43+
44+
// When it is Feb 23 in Oslo, it is not yet (by 1 hour) Feb 23rd in GMT.
45+
var inOsloTime = Globalize.dateParser({skeleton: "MMMd", timeZone: "Europe/Oslo"})("Feb 23");
46+
expect(inOsloTime.getUTCMonth()).to.equal(1);
47+
expect(inOsloTime.getUTCDate()).to.equal(22);
4248
});
4349

4450
it("should include support for parseDate", function() {

test/unit/fixtures/basic.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ console.log(Globalize.formatDateToParts(new Date(), {date: "long"}));
2929
var dateParser = Globalize.dateParser({skeleton: "MMMd", timeZone: "America/New_York"});
3030
console.log(dateParser("Jan 1"));
3131

32+
dateParser = Globalize.dateParser({skeleton: "MMMd", timeZone: "Europe/Oslo"});
33+
console.log(dateParser("Jan 1"));
34+
3235
// Use parseDate.
3336
console.log(Globalize.parseDate("1/2/1982"));
3437

0 commit comments

Comments
 (0)