mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 23:37:33 +09:00
[Basilisk] Issue #31 - Part 3: Use nsIScriptableDateFormat in places library window.
This commit is contained in:
parent
ad9127aad4
commit
443bc25ce0
2 changed files with 27 additions and 35 deletions
|
|
@ -33,6 +33,15 @@ PlacesTreeView.prototype = {
|
|||
return this.__xulStore;
|
||||
},
|
||||
|
||||
__dateService: null,
|
||||
get _dateService() {
|
||||
if (!this.__dateService) {
|
||||
this.__dateService = Cc["@mozilla.org/intl/scriptabledateformat;1"].
|
||||
getService(Ci.nsIScriptableDateFormat);
|
||||
}
|
||||
return this.__dateService;
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI(PTV_interfaces),
|
||||
|
||||
// Bug 761494:
|
||||
|
|
@ -495,36 +504,16 @@ PlacesTreeView.prototype = {
|
|||
let midnight = now - (now % MS_PER_DAY);
|
||||
midnight += new Date(midnight).getTimezoneOffset() * MS_PER_MINUTE;
|
||||
|
||||
let dateFormat = timeMs >= midnight ?
|
||||
Ci.nsIScriptableDateFormat.dateFormatNone :
|
||||
Ci.nsIScriptableDateFormat.dateFormatShort;
|
||||
|
||||
let timeObj = new Date(timeMs);
|
||||
return timeMs >= midnight ? this._todayFormatter.format(timeObj)
|
||||
: this._dateFormatter.format(timeObj);
|
||||
},
|
||||
|
||||
// We use a different formatter for times within the current day,
|
||||
// so we cache both a "today" formatter and a general date formatter.
|
||||
__todayFormatter: null,
|
||||
get _todayFormatter() {
|
||||
if (!this.__todayFormatter) {
|
||||
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIXULChromeRegistry)
|
||||
.getSelectedLocale("global", true);
|
||||
const dtOptions = { hour: 'numeric', minute: 'numeric' };
|
||||
this.__todayFormatter = new Intl.DateTimeFormat(locale, dtOptions);
|
||||
}
|
||||
return this.__todayFormatter;
|
||||
},
|
||||
|
||||
__dateFormatter: null,
|
||||
get _dateFormatter() {
|
||||
if (!this.__dateFormatter) {
|
||||
const locale = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIXULChromeRegistry)
|
||||
.getSelectedLocale("global", true);
|
||||
const dtOptions = { year: 'numeric', month: 'numeric', day: 'numeric',
|
||||
hour: 'numeric', minute: 'numeric' };
|
||||
this.__dateFormatter = new Intl.DateTimeFormat(locale, dtOptions);
|
||||
}
|
||||
return this.__dateFormatter;
|
||||
return (this._dateService.FormatDateTime("", dateFormat,
|
||||
Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
|
||||
timeObj.getFullYear(), timeObj.getMonth() + 1,
|
||||
timeObj.getDate(), timeObj.getHours(),
|
||||
timeObj.getMinutes(), timeObj.getSeconds()));
|
||||
},
|
||||
|
||||
COLUMN_TYPE_UNKNOWN: 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue