www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 7445f81042f90448b64a6b9c4ac67856078ab4e6
parent 28301ea45fe8709b2553a4792232ae45a6f25f55
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date:   Tue, 10 Mar 2015 19:42:22 -0500

Port Zotero.Date.sqlToISO8601 from 755ead21194f57d11f00e80754d501ac0158bfb6
Copy-pasted, no modifications

Diffstat:
Mchrome/content/zotero/xpcom/date.js | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js @@ -544,6 +544,29 @@ Zotero.Date = new function(){ return false; } + + this.sqlToISO8601 = function (sqlDate) { + var date = sqlDate.substr(0, 10); + var matches = date.match(/^([0-9]{4})\-([0-9]{2})\-([0-9]{2})/); + if (!matches) { + return false; + } + date = matches[1]; + // Drop parts for reduced precision + if (matches[2] !== "00") { + date += "-" + matches[2]; + if (matches[3] !== "00") { + date += "-" + matches[3]; + } + } + var time = sqlDate.substr(11); + // TODO: validate times + if (time) { + date += "T" + time + "Z"; + } + return date; + } + function strToMultipart(str){ if (!str){ return '';