From dc045250a6e7471b16748e25d37f2b0099c12d3e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 8 Jun 2022 23:45:18 -0400 Subject: [PATCH] Fix parsing of Chinese and other non-ASCII month names https://forums.zotero.org/discussion/97683/bug-locale-issues-concerning-zotero-and-zotero-connector --- chrome/content/zotero/xpcom/utilities | 2 +- test/tests/dateTest.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/utilities b/chrome/content/zotero/xpcom/utilities index a0a145a4b5..e4a8d2695c 160000 --- a/chrome/content/zotero/xpcom/utilities +++ b/chrome/content/zotero/xpcom/utilities @@ -1 +1 @@ -Subproject commit a0a145a4b534721148da362a3bae3befc8d65121 +Subproject commit e4a8d2695c34ab7977fcf2a73720546c1c43560c diff --git a/test/tests/dateTest.js b/test/tests/dateTest.js index 5d6ba7520c..6dcf84d2b2 100644 --- a/test/tests/dateTest.js +++ b/test/tests/dateTest.js @@ -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;