Fix parsing of Chinese and other non-ASCII month names

https://forums.zotero.org/discussion/97683/bug-locale-issues-concerning-zotero-and-zotero-connector
This commit is contained in:
Dan Stillman 2022-06-08 23:45:18 -04:00
parent 256bd157ed
commit dc045250a6
2 changed files with 17 additions and 1 deletions

@ -1 +1 @@
Subproject commit a0a145a4b534721148da362a3bae3befc8d65121
Subproject commit e4a8d2695c34ab7977fcf2a73720546c1c43560c

View file

@ -164,6 +164,13 @@ describe("Zotero.Date", function() {
})
describe("#strToDate()", function () {
beforeEach(function () {
if (Zotero.locale != 'en-US') {
Zotero.locale = 'en-US';
Zotero.Date.init();
}
});
it("should return object without date parts for null", function () {
var o = Zotero.Date.strToDate(null);
assert.notProperty(o, 'year');
@ -189,6 +196,15 @@ describe("Zotero.Date", function() {
assert.notProperty(o, 'year');
});
it("should parse Chinese month", function () {
Zotero.locale = 'zh-CN';
Zotero.Date.init();
var o = Zotero.Date.strToDate("四月 26, 2010");
assert.equal(o.month, 3);
assert.equal(o.day, 26);
assert.equal(o.year, 2010);
});
it("should parse two- and three-digit dates with leading zeros", function () {
var o;