Add big-endian date countries and use different format based on order
m/d/yy, yyyy-mm-dd, and d.m.yy, based on what seem to be the most common variants for each order.
This commit is contained in:
parent
d453a15066
commit
61c0f974c0
|
@ -662,20 +662,43 @@ Zotero.Date = new function(){
|
|||
}
|
||||
|
||||
/**
|
||||
* Figure out the date order from the output of toLocaleDateString()
|
||||
* Get the order of the date components based on the current locale
|
||||
*
|
||||
* Returns a string with y, m, and d (e.g. 'ymd', 'mdy')
|
||||
*/
|
||||
function getLocaleDateOrder(){
|
||||
if (!_localeDateOrder) {
|
||||
switch (Zotero.locale.substr(3)) {
|
||||
switch (Zotero.locale.substr(-2)) {
|
||||
// middle-endian
|
||||
case 'US': // The United States
|
||||
case 'BZ': // Belize
|
||||
case 'FM': // The Federated States of Micronesia
|
||||
case 'PW': // Palau
|
||||
case 'PA': // Panama
|
||||
case 'PH': // The Philippines
|
||||
case 'PW': // Palau
|
||||
case 'ZW': // Zimbabwe
|
||||
_localeDateOrder = 'mdy';
|
||||
break;
|
||||
|
||||
|
||||
// big-endian
|
||||
case 'fa': // Persian
|
||||
case 'AL': // Albania
|
||||
case 'CA': // Canada
|
||||
case 'CN': // China
|
||||
case 'HU': // Hungary
|
||||
case 'JP': // Japan
|
||||
case 'KE': // Kenya
|
||||
case 'KR': // Korea
|
||||
case 'LT': // Lithuania
|
||||
case 'LV': // Latvia
|
||||
case 'MN': // Mongolia
|
||||
case 'SE': // Sweden
|
||||
case 'TW': // Taiwan
|
||||
case 'ZA': // South Africa
|
||||
_localeDateOrder = 'ymd';
|
||||
break;
|
||||
|
||||
// little-endian
|
||||
default:
|
||||
_localeDateOrder = 'dmy';
|
||||
}
|
||||
|
|
|
@ -759,6 +759,18 @@ Zotero.ItemTreeView.prototype.getCellText = function(row, column)
|
|||
case 'zotero-items-column-accessDate':
|
||||
if (val) {
|
||||
var order = Zotero.Date.getLocaleDateOrder();
|
||||
if (order == 'mdy') {
|
||||
order = 'mdy';
|
||||
var join = '/';
|
||||
}
|
||||
else if (order == 'dmy') {
|
||||
order = 'dmy';
|
||||
var join = '.';
|
||||
}
|
||||
else if (order == 'ymd') {
|
||||
order = 'YMD';
|
||||
var join = '-';
|
||||
}
|
||||
var date = Zotero.Date.sqlToDate(val, true);
|
||||
var parts = [];
|
||||
for (var i=0; i<3; i++) {
|
||||
|
@ -767,16 +779,28 @@ Zotero.ItemTreeView.prototype.getCellText = function(row, column)
|
|||
parts.push(date.getFullYear().toString().substr(2));
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
parts.push(date.getFullYear());
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
parts.push((date.getMonth() + 1));
|
||||
break;
|
||||
|
||||
|
||||
case 'M':
|
||||
parts.push(Zotero.Utilities.lpad((date.getMonth() + 1).toString(), '0', 2));
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
parts.push(date.getDate());
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
parts.push(Zotero.Utilities.lpad(date.getDate().toString(), '0', 2));
|
||||
break;
|
||||
}
|
||||
|
||||
val = parts.join('/');
|
||||
val = parts.join(join);
|
||||
val += ' ' + date.toLocaleTimeString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user