зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1354445 - Migrate Intl.DateTimeFormat to mozIntl.DateTimeFormat in chrome. r=mak
MozReview-Commit-ID: 4z13lcLXN9T --HG-- extra : rebase_source : 8043212542b95ca76cf5957fa1ca05e6943fb635
This commit is contained in:
Родитель
37ee2e02bb
Коммит
9f6c244d29
|
@ -355,7 +355,9 @@ var AboutNetAndCertErrorListener = {
|
|||
|
||||
// If the difference is more than a day.
|
||||
if (Math.abs(difference) > 60 * 60 * 24) {
|
||||
let formatter = new Intl.DateTimeFormat();
|
||||
let formatter = Services.intl.createDateTimeFormat(undefined, {
|
||||
dateStyle: "short"
|
||||
});
|
||||
let systemDate = formatter.format(new Date());
|
||||
// negative difference means local time is behind server time
|
||||
let actualDate = formatter.format(new Date(Date.now() - difference * 1000));
|
||||
|
@ -385,7 +387,9 @@ var AboutNetAndCertErrorListener = {
|
|||
let systemDate = new Date();
|
||||
|
||||
if (buildDate > systemDate) {
|
||||
let formatter = new Intl.DateTimeFormat();
|
||||
let formatter = Services.intl.createDateTimeFormat(undefined, {
|
||||
dateStyle: "short"
|
||||
});
|
||||
|
||||
content.document.getElementById("wrongSystemTimeWithoutReference_URL")
|
||||
.textContent = content.document.location.hostname;
|
||||
|
|
|
@ -151,7 +151,9 @@ add_task(function* checkWrongSystemTimeWarning() {
|
|||
});
|
||||
}
|
||||
|
||||
let formatter = new Intl.DateTimeFormat();
|
||||
let formatter = Services.intl.createDateTimeFormat(undefined, {
|
||||
dateStyle: "short"
|
||||
});
|
||||
|
||||
// pretend we have a positively skewed (ahead) system time
|
||||
let serverDate = new Date("2015/10/27");
|
||||
|
|
|
@ -189,9 +189,11 @@ FeedWriter.prototype = {
|
|||
__dateFormatter: null,
|
||||
get _dateFormatter() {
|
||||
if (!this.__dateFormatter) {
|
||||
const dtOptions = { year: "numeric", month: "long", day: "numeric",
|
||||
hour: "numeric", minute: "numeric" };
|
||||
this.__dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
|
||||
const dtOptions = {
|
||||
timeStyle: "short",
|
||||
dateStyle: "long"
|
||||
};
|
||||
this.__dateFormatter = Services.intl.createDateTimeFormat(undefined, dtOptions);
|
||||
}
|
||||
return this.__dateFormatter;
|
||||
},
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/TelemetryStopwatch.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "MigrationUtils",
|
||||
"resource:///modules/MigrationUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
|
@ -411,8 +412,10 @@ var PlacesOrganizer = {
|
|||
populateRestoreMenu: function PO_populateRestoreMenu() {
|
||||
let restorePopup = document.getElementById("fileRestorePopup");
|
||||
|
||||
const dtOptions = { year: "numeric", month: "long", day: "numeric" };
|
||||
let dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
|
||||
const dtOptions = {
|
||||
dateStyle: "long"
|
||||
};
|
||||
let dateFormatter = Services.intl.createDateTimeFormat(undefined, dtOptions);
|
||||
|
||||
// Remove existing menu items. Last item is the restoreFromFile item.
|
||||
while (restorePopup.childNodes.length > 1)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const PTV_interfaces = [Ci.nsITreeView,
|
||||
Ci.nsINavHistoryResultObserver,
|
||||
|
@ -499,8 +500,8 @@ PlacesTreeView.prototype = {
|
|||
__todayFormatter: null,
|
||||
get _todayFormatter() {
|
||||
if (!this.__todayFormatter) {
|
||||
const dtOptions = { hour: "numeric", minute: "numeric" };
|
||||
this.__todayFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
|
||||
const dtOptions = { timeStyle: "short" };
|
||||
this.__todayFormatter = Services.intl.createDateTimeFormat(undefined, dtOptions);
|
||||
}
|
||||
return this.__todayFormatter;
|
||||
},
|
||||
|
@ -508,9 +509,11 @@ PlacesTreeView.prototype = {
|
|||
__dateFormatter: null,
|
||||
get _dateFormatter() {
|
||||
if (!this.__dateFormatter) {
|
||||
const dtOptions = { year: "numeric", month: "numeric", day: "numeric",
|
||||
hour: "numeric", minute: "numeric" };
|
||||
this.__dateFormatter = new Intl.DateTimeFormat(undefined, dtOptions);
|
||||
const dtOptions = {
|
||||
dateStyle: "short",
|
||||
timeStyle: "short"
|
||||
};
|
||||
this.__dateFormatter = Services.intl.createDateTimeFormat(undefined, dtOptions);
|
||||
}
|
||||
return this.__dateFormatter;
|
||||
},
|
||||
|
|
|
@ -124,18 +124,21 @@
|
|||
case "date":
|
||||
let timeObj = new Date(node.time / 1000);
|
||||
// Default is short date format.
|
||||
let dtOptions = { year: 'numeric', month: 'numeric', day: 'numeric',
|
||||
hour: 'numeric', minute: 'numeric' };
|
||||
let dtOptions = {
|
||||
dateStyle: "short",
|
||||
timeStyle: "short"
|
||||
};
|
||||
|
||||
// For today's visits we don't show date portion.
|
||||
if (node.uri == "http://at.midnight.com/" ||
|
||||
node.uri == "http://after.midnight.com/") {
|
||||
dtOptions = { hour: 'numeric', minute: 'numeric' };
|
||||
dtOptions.dateStyle = undefined;
|
||||
} else if (node.uri != "http://before.midnight.com/") {
|
||||
// Avoid to test spurious uris, due to how the test works
|
||||
// a redirecting uri could be put in the tree while we test.
|
||||
break;
|
||||
}
|
||||
let timeStr = timeObj.toLocaleString(undefined, dtOptions);
|
||||
let timeStr = Services.intl.createDateTimeFormat(undefined, dtOptions).format(timeObj);
|
||||
|
||||
is(text, timeStr, "Date format is correct");
|
||||
break;
|
||||
|
|
|
@ -1442,8 +1442,7 @@ function UserAutoCompleteResult(aSearchString, matchingLogins, {isSecure, messag
|
|||
this.matchCount = matchingLogins.length + this._showInsecureFieldWarning;
|
||||
this._messageManager = messageManager;
|
||||
this._stringBundle = Services.strings.createBundle("chrome://passwordmgr/locale/passwordmgr.properties");
|
||||
this._dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric" });
|
||||
this._dateAndTimeFormatter = Services.intl.createDateTimeFormat(undefined, { dateStyle: "medium" });
|
||||
|
||||
this._isPasswordField = isPasswordField;
|
||||
|
||||
|
|
|
@ -191,9 +191,7 @@ XPCOMUtils.defineLazyGetter(LoginManagerContextMenu, "_stringBundle", function()
|
|||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(LoginManagerContextMenu, "dateAndTimeFormatter", function() {
|
||||
return new Intl.DateTimeFormat(undefined, {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
return Services.intl.createDateTimeFormat(undefined, {
|
||||
dateStyle: "medium"
|
||||
});
|
||||
});
|
||||
|
|
|
@ -59,11 +59,11 @@ let signonReloadDisplay = {
|
|||
};
|
||||
|
||||
// Formatter for localization.
|
||||
let dateFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric" });
|
||||
let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric",
|
||||
hour: "numeric", minute: "numeric" });
|
||||
let dateFormatter = Services.intl.createDateTimeFormat(undefined,
|
||||
{ dateStyle: "medium" });
|
||||
let dateAndTimeFormatter = Services.intl.createDateTimeFormat(undefined,
|
||||
{ dateStyle: "medium",
|
||||
timeStyle: "short" });
|
||||
|
||||
function Startup() {
|
||||
// be prepared to reload the display if anything changes
|
||||
|
|
|
@ -94,6 +94,9 @@ var setupScript = runInParent(function setup() {
|
|||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
let { Services } =
|
||||
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
|
||||
/** Test for Login Manager: multiple login autocomplete. **/
|
||||
|
||||
var uname = $_(1, "uname");
|
||||
|
@ -128,8 +131,8 @@ function* reinitializeForm(index) {
|
|||
}
|
||||
|
||||
function generateDateString(date) {
|
||||
let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric" });
|
||||
let dateAndTimeFormatter = Services.intl.createDateTimeFormat(undefined,
|
||||
{ dateStyle: "medium" });
|
||||
return dateAndTimeFormatter.format(date);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ function checkLoginItems(logins, items) {
|
|||
}
|
||||
let duplicates = findDuplicates(logins);
|
||||
|
||||
let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric" });
|
||||
let dateAndTimeFormatter = Services.intl.createDateTimeFormat(undefined,
|
||||
{ dateStyle: "medium" });
|
||||
for (let login of logins) {
|
||||
if (login.username && !duplicates.has(login.username)) {
|
||||
// If login is not duplicate and we can't find an item for it, fail.
|
||||
|
|
|
@ -24,8 +24,8 @@ matchingLogins.push(new nsLoginInfo("http://mochi.test:8888", "http://autocomple
|
|||
"zzzuser4", "zzzpass4", "uname", "pword"));
|
||||
|
||||
let meta = matchingLogins[0].QueryInterface(Ci.nsILoginMetaInfo);
|
||||
let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
|
||||
{ day: "numeric", month: "short", year: "numeric" });
|
||||
let dateAndTimeFormatter = Services.intl.createDateTimeFormat(undefined,
|
||||
{ dateStyle: "medium" });
|
||||
let time = dateAndTimeFormatter.format(new Date(meta.timePasswordChanged));
|
||||
const LABEL_NO_USERNAME = "No username (" + time + ")";
|
||||
|
||||
|
|
|
@ -78,11 +78,8 @@ function populateReportList() {
|
|||
var dateFormatter;
|
||||
var timeFormatter;
|
||||
try {
|
||||
dateFormatter = new Intl.DateTimeFormat(undefined, { year: "2-digit",
|
||||
month: "numeric",
|
||||
day: "numeric" });
|
||||
timeFormatter = new Intl.DateTimeFormat(undefined, { hour: "numeric",
|
||||
minute: "numeric" });
|
||||
dateFormatter = Services.intl.createDateTimeFormat(undefined, { dateStyle: "short" });
|
||||
timeFormatter = Services.intl.createDateTimeFormat(undefined, { timeStyle: "short" });
|
||||
} catch (e) {
|
||||
// XXX Fallback to be removed once bug 1215247 is complete
|
||||
// and the Intl API is available on all platforms.
|
||||
|
|
|
@ -75,6 +75,7 @@ var initTable = [
|
|||
["els", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"],
|
||||
["eTLD", "@mozilla.org/network/effective-tld-service;1", "nsIEffectiveTLDService"],
|
||||
["io", "@mozilla.org/network/io-service;1", "nsIIOService2"],
|
||||
["intl", "@mozilla.org/mozintl;1", "mozIMozIntl"],
|
||||
["locale", "@mozilla.org/intl/localeservice;1", "mozILocaleService"],
|
||||
["logins", "@mozilla.org/login-manager;1", "nsILoginManager"],
|
||||
["obs", "@mozilla.org/observer-service;1", "nsIObserverService"],
|
||||
|
|
|
@ -45,6 +45,7 @@ function run_test() {
|
|||
checkService("focus", Ci.nsIFocusManager);
|
||||
checkService("io", Ci.nsIIOService);
|
||||
checkService("io", Ci.nsIIOService2);
|
||||
checkService("intl", Ci.mozIMozIntl);
|
||||
checkService("locale", Ci.mozILocaleService);
|
||||
checkService("logins", Ci.nsILoginManager);
|
||||
checkService("obs", Ci.nsIObserverService);
|
||||
|
|
Загрузка…
Ссылка в новой задаче