/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if JS_HAS_INTL_API // This cache, once primed, has these properties: // // runtimeDefaultLocale: // Locale information provided by the embedding, guiding SpiderMonkey's // selection of a default locale. See intl_RuntimeDefaultLocale(), whose // value controls the value returned by DefaultLocale() that's what's // *actually* used. // icuDefaultTimeZone: // Time zone information provided by ICU. See intl_defaultTimeZone(), // whose value controls the value returned by DefaultTimeZone() that's // what's *actually* used. // formatters: // A Record storing formatters consistent with the above // runtimeDefaultLocale/localTZA values, for use with the appropriate // ES6 toLocale*String Date method when called with its first two // arguments having the value |undefined|. // // The "formatters" Record has (some subset of) these properties, as determined // by all values of the first argument passed to |GetCachedFormat|: // // dateTimeFormat: for Date's toLocaleString operation // dateFormat: for Date's toLocaleDateString operation // timeFormat: for Date's toLocaleTimeString operation // // Using this cache, then, requires // 1) verifying the current runtimeDefaultLocale/icuDefaultTimeZone are // consistent with cached values, then // 2) seeing if the desired formatter is cached and returning it if so, or else // 3) create the desired formatter and store and return it. var dateTimeFormatCache = new_Record();
/** *GetacachedDateTimeFormatformatterobject,createdlikeso: * *CreateDateTimeFormat(undefined,undefined,required,defaults); * *|format|mustbeakeyfromthe"formatters"Recorddescribedabove.
*/ function GetCachedFormat(format, required, defaults) { assert(
format === "dateTimeFormat" ||
format === "dateFormat" ||
format === "timeFormat", "unexpected format key: please update the comment by dateTimeFormatCache"
);
// Step 5-6. var dateTimeFormat; if (locales === undefined && options === undefined) { // This cache only optimizes for the old ES5 toLocaleString without // locales and options.
dateTimeFormat = GetCachedFormat("dateTimeFormat", "any", "all");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "any", "all");
}
// Step 5-6. var dateTimeFormat; if (locales === undefined && options === undefined) { // This cache only optimizes for the old ES5 toLocaleDateString without // locales and options.
dateTimeFormat = GetCachedFormat("dateFormat", "date", "date");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "date", "date");
}
// Step 5-6. var dateTimeFormat; if (locales === undefined && options === undefined) { // This cache only optimizes for the old ES5 toLocaleTimeString without // locales and options.
dateTimeFormat = GetCachedFormat("timeFormat", "time", "time");
} else {
dateTimeFormat = intl_CreateDateTimeFormat(locales, options, "time", "time");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.