Skip to content

Commit

Permalink
Merge pull request #143 from felixge/epoch-time-error
Browse files Browse the repository at this point in the history
Fixed Invalid '1970-01-01' Formatting
  • Loading branch information
chase-manning authored Dec 4, 2020
2 parents e825fa8 + 3a238d9 commit a625c5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dateformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
date = undefined;
}

date = date || new Date();
date = date || date === 0 ? date : new Date();

if (!(date instanceof Date)) {
date = new Date(date);
Expand Down
14 changes: 8 additions & 6 deletions test/test_isoutcdatetime.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
var assert = require('assert');
var assert = require("assert");

var dateFormat = require('./../lib/dateformat');
var dateFormat = require("./../lib/dateformat");

describe('isoUtcDateTime', function() {
it('should correctly format the timezone part', function(done) {
var actual = dateFormat('2014-06-02T13:23:21-08:00', 'isoUtcDateTime');
assert.strictEqual(actual, '2014-06-02T21:23:21Z');
describe("isoUtcDateTime", function () {
it("should correctly format the timezone part", function (done) {
var actual = dateFormat("2014-06-02T13:23:21-08:00", "isoUtcDateTime");
assert.strictEqual(actual, "2014-06-02T21:23:21Z");
var epochTime = dateFormat(0, "isoUtcDateTime");
assert.strictEqual(epochTime, "1970-01-01T00:00:00Z");
done();
});
});

0 comments on commit a625c5c

Please sign in to comment.