strToDate(): Fix 'order' for just a number <=12

"m" instead of "m y"
This commit is contained in:
Dan Stillman 2020-05-28 04:32:14 -04:00
parent 70b361ed8b
commit 85bc5d168e
2 changed files with 5 additions and 1 deletions

View file

@ -312,7 +312,9 @@ Zotero.Date = new function(){
date.order += m[4] ? 'm' : '';
}
date.year = m[6];
date.order += 'y';
if (m[6] !== undefined) {
date.order += 'y';
}
}
var zeroYear = date.year && date.year.toString().startsWith('0');

View file

@ -207,6 +207,7 @@ describe("Zotero.Date", function() {
var o = Zotero.Date.strToDate('1');
assert.equal(o.month, 0);
assert.isUndefined(o.year);
assert.equal(o.order, 'm');
});
it("should parse string with just day number", function () {
@ -214,6 +215,7 @@ describe("Zotero.Date", function() {
assert.equal(o.day, 25);
assert.isUndefined(o.month);
assert.isUndefined(o.year);
assert.equal(o.order, 'd');
});
it("should work in translator sandbox", function* () {