strToDate(): Don't parse 01/01/08 as the year 8

Regression from b7dc0d8b0a (5.0.81)
This commit is contained in:
Dan Stillman 2020-05-28 06:18:21 -04:00
parent c882488ef7
commit 0620b16d3e
2 changed files with 20 additions and 7 deletions

View file

@ -183,14 +183,25 @@ describe("Zotero.Date", function() {
});
it("should parse two- and three-digit dates with leading zeros", function () {
var o = Zotero.Date.strToDate('0068');
assert.equal(o.year, 68);
var o;
o = Zotero.Date.strToDate('068');
assert.equal(o.year, 68);
o = Zotero.Date.strToDate('001');
assert.equal(o.year, 1);
o = Zotero.Date.strToDate('0168');
assert.equal(o.year, 168);
o = Zotero.Date.strToDate('0001');
assert.equal(o.year, 1);
o = Zotero.Date.strToDate('012');
assert.equal(o.year, 12);
o = Zotero.Date.strToDate('0012');
assert.equal(o.year, 12);
o = Zotero.Date.strToDate('0123');
assert.equal(o.year, 123);
o = Zotero.Date.strToDate('01/01/08');
assert.equal(o.year, 2008);
});
it("should parse two-digit year greater than current year as previous century", function () {