www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 75bf69526c081a424549dbb3aa3a768887750c4f
parent c18675801f25e584d61f0375d7bc2e693e7e84c0
Author: Dan Stillman <dstillman@zotero.org>
Date:   Sun, 13 Mar 2016 20:00:29 -0400

Daylight saving time: it's a thing!

Diffstat:
Mtest/tests/dateTest.js | 22++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/test/tests/dateTest.js b/test/tests/dateTest.js @@ -1,10 +1,24 @@ describe("Zotero.Date", function() { describe("#sqlToDate()", function () { it("should convert an SQL local date into a JS Date object", function* () { - var date = "2016-02-27 22:00:00"; - var offset = new Date().getTimezoneOffset() * 60 * 1000; - date = Zotero.Date.sqlToDate(date); - assert.equal(date.getTime(), 1456610400000 + offset); + var d1 = new Date(); + var sqlDate = d1.getFullYear() + + '-' + + Zotero.Utilities.lpad(d1.getMonth() + 1, '0', 2) + + '-' + + Zotero.Utilities.lpad(d1.getDate(), '0', 2) + + ' ' + + Zotero.Utilities.lpad(d1.getHours(), '0', 2) + + ':' + + Zotero.Utilities.lpad(d1.getMinutes(), '0', 2) + + ':' + + Zotero.Utilities.lpad(d1.getSeconds(), '0', 2); + var offset = d1.getTimezoneOffset() * 60 * 1000; + var d2 = Zotero.Date.sqlToDate(sqlDate); + assert.equal( + Zotero.Date.sqlToDate(sqlDate).getTime(), + Math.floor(new Date().getTime() / 1000) * 1000 + ); }) it("should convert an SQL UTC date into a JS Date object", function* () {