From d453a15066da487c43473ec40b1115215da67c30 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 29 Feb 2012 03:27:18 -0500 Subject: [PATCH] Fix middle-pane Date Added/Modified order for non-US Mac/Linux --- chrome/content/zotero/xpcom/date.js | 75 +++++------------------------ 1 file changed, 13 insertions(+), 62 deletions(-) diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js index ba54e4e19e..a84c58f88b 100644 --- a/chrome/content/zotero/xpcom/date.js +++ b/chrome/content/zotero/xpcom/date.js @@ -667,68 +667,19 @@ Zotero.Date = new function(){ * Returns a string with y, m, and d (e.g. 'ymd', 'mdy') */ function getLocaleDateOrder(){ - if (_localeDateOrder) { - return _localeDateOrder; + if (!_localeDateOrder) { + switch (Zotero.locale.substr(3)) { + case 'US': // The United States + case 'FM': // The Federated States of Micronesia + case 'PW': // Palau + case 'PH': // The Philippines + _localeDateOrder = 'mdy'; + break; + + default: + _localeDateOrder = 'dmy'; + } } - - var date = new Date("October 5, 2006"); - var parts = date.toLocaleDateString().match(/([0-9]+)[^0-9]+([0-9]+)[^0-9]+([0-9]+)/); - - // The above only works on OS X and Linux, - // where toLocaleDateString() produces "10/05/2006" - if (!parts) { - var country = Zotero.locale.substr(3); - switch (country) { - // I don't know where this country list came from, but these - // are little-endian in Zotero.strToDate() - case 'US': // The United States - case 'FM': // The Federated States of Micronesia - case 'PW': // Palau - case 'PH': // The Philippines - return 'mdy'; - break; - - default: - return 'dmy'; - } - } - - switch (parseInt(parts[1])){ - case 2006: - var order = 'y'; - break; - case 10: - var order = 'm'; - break; - case 5: - var order = 'd'; - break; - } - switch (parseInt(parts[2])){ - case 2006: - order += 'y'; - break; - case 10: - order += 'm'; - break; - case 5: - order += 'd'; - break; - } - switch (parseInt(parts[3])){ - case 2006: - order += 'y'; - break; - case 10: - order += 'm'; - break; - case 5: - order += 'd'; - break; - } - - _localeDateOrder = order; - - return order; + return _localeDateOrder; } } \ No newline at end of file