Use proper locale format for dates in items list
2addf6b27b
fixed the date order used when automatic locale detection was
enabled, but this fixes the format (e.g., dots instead of slashes). It
should now match the item pane. I'm not sure why we weren't doing this
before, but hopefully we didn't have a good reason.
This commit is contained in:
parent
a9f0096929
commit
05ea309e2e
1 changed files with 12 additions and 43 deletions
|
@ -1073,50 +1073,19 @@ Zotero.ItemTreeView.prototype.getCellText = function (row, column)
|
|||
break;
|
||||
}
|
||||
if (val) {
|
||||
var order = Zotero.Date.getLocaleDateOrder();
|
||||
if (order == 'mdy') {
|
||||
order = 'mdy';
|
||||
var join = '/';
|
||||
let date = Zotero.Date.sqlToDate(val, true);
|
||||
if (date) {
|
||||
// If no time, interpret as local, not UTC
|
||||
if (Zotero.Date.isSQLDate(val)) {
|
||||
date = Zotero.Date.sqlToDate(val);
|
||||
val = date.toLocaleDateString();
|
||||
}
|
||||
else if (order == 'dmy') {
|
||||
order = 'dmy';
|
||||
var join = '/';
|
||||
else {
|
||||
val = date.toLocaleString();
|
||||
}
|
||||
else if (order == 'ymd') {
|
||||
order = 'YMD';
|
||||
var join = '-';
|
||||
}
|
||||
var date = Zotero.Date.sqlToDate(val, true);
|
||||
var parts = [];
|
||||
for (var i=0; i<3; i++) {
|
||||
switch (order[i]) {
|
||||
case 'y':
|
||||
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(join);
|
||||
val += ' ' + date.toLocaleTimeString();
|
||||
else {
|
||||
val = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue