-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow moment.fn.utc to clear the timezone flag #86
- Loading branch information
Showing
2 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use strict"; | ||
|
||
var moment = require("../../"); | ||
|
||
exports.utc = { | ||
utc : function (test) { | ||
moment.tz.add([ | ||
"TestUTC/Pacific|PST|80|0|", | ||
"TestUTC/Eastern|EST|50|0|" | ||
]); | ||
|
||
var m = moment("2014-07-10 12:00:00+00:00"), | ||
localFormat = m.format(), | ||
localZone = m.zone(); | ||
|
||
m.tz("TestUTC/Pacific"); | ||
|
||
test.equal(m.zone(), 480, "Should change the offset when using moment.fn.tz"); | ||
test.equal(m.format(), "2014-07-10T04:00:00-08:00", "Should change the offset when using moment.fn.tz"); | ||
|
||
m.utc(); | ||
moment.updateOffset(m); | ||
|
||
test.equal(m.zone(), 0, "Should set the offset to +00:00 when using moment.fn.utc"); | ||
test.equal(m.format(), "2014-07-10T12:00:00+00:00", "Should change the offset when using moment.fn.utc"); | ||
|
||
m.tz("TestUTC/Eastern"); | ||
|
||
test.equal(m.zone(), 300, "Should change the offset when using moment.fn.tz"); | ||
test.equal(m.format(), "2014-07-10T07:00:00-05:00", "Should change the offset when using moment.fn.tz"); | ||
|
||
m.utc(); | ||
moment.updateOffset(m); | ||
|
||
test.equal(m.zone(), 0, "Should set the offset to +00:00 when using moment.fn.utc"); | ||
test.equal(m.format(), "2014-07-10T12:00:00+00:00", "Should change the offset when using moment.fn.utc"); | ||
|
||
m.local(); | ||
moment.updateOffset(m); | ||
|
||
test.equal(m.zone(), localZone, "Should reset the offset to local time when using moment.fn.local"); | ||
test.equal(m.format(), localFormat, "Should reset the offset to local time when using moment.fn.local"); | ||
|
||
test.done(); | ||
} | ||
}; |