web-library icon indicating copy to clipboard operation
web-library copied to clipboard

Locale-aware date parsing

Open dstillman opened this issue 3 years ago • 0 comments

So this is sort of fundamentally broken, without a real fix possible in web-library itself, but it may be improvable.

We got a report that someone was using the desktop app with a locale that parses dates as dd/mm/yy, and then they checked the web library and it parsed a date as mm/dd/yy, which produces incorrect results for sorting, citation output, export, etc.

I didn't test this, so I'm not sure if they were just using web-library with a browser set to English and we're currently parsing dates based on the browser locale — that would be roughly equivalent to what we're doing in-app. If not (and maybe even if we are, using a different library), we should use our date-parsing function, strToDate(), which is now available in the zotero/utilities repo. It will check Zotero.locale and parse accordingly. (It's currently missing non-English month names, which are normally set by Zotero.Date.init(), which can't currently be run outside of Zotero, but we'll fix that separately.)

Unfortunately this would still mean that different people could see different dates for the same item — which is also possible with the desktop app in Zotero groups, or even for one person with multiple computers with different locale settings. To fix this properly, we probably need to start storing and syncing fully parsed dates as EDTF and discarding the ambiguous original strings, but that's a whole other thing. In any case, parsing based on the browser locale would fix this for many people.

dstillman avatar Aug 20 '21 11:08 dstillman