tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IntlObject.js (1911B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /**
      6 * This function is a custom function in the style of the standard Intl.*
      7 * functions, that isn't part of any spec or proposal yet.
      8 *
      9 * Returns an object with the following properties:
     10 *   locale:
     11 *     The actual resolved locale.
     12 *
     13 *   calendar:
     14 *     The default calendar of the resolved locale.
     15 *
     16 *   firstDayOfWeek:
     17 *     The first day of the week for the resolved locale.
     18 *
     19 *   minDays:
     20 *     The minimum number of days in a week for the resolved locale.
     21 *
     22 *   weekend:
     23 *     The days of the week considered as the weekend for the resolved locale.
     24 *
     25 * Days are encoded as integers in the range 1=Monday to 7=Sunday.
     26 */
     27 function Intl_getCalendarInfo(locales) {
     28  // 1. Let requestLocales be ? CanonicalizeLocaleList(locales).
     29  var requestedLocales = CanonicalizeLocaleList(locales);
     30 
     31  var DateTimeFormat = dateTimeFormatInternalProperties;
     32 
     33  // 2. Let localeData be %DateTimeFormat%.[[localeData]].
     34  var localeData = DateTimeFormat.localeData;
     35 
     36  // 3. Let localeOpt be a new Record.
     37  var localeOpt = NEW_RECORD();
     38 
     39  // 4. Set localeOpt.[[localeMatcher]] to "best fit".
     40  localeOpt.localeMatcher = "best fit";
     41 
     42  // 5. Let r be ResolveLocale(%DateTimeFormat%.[[availableLocales]],
     43  //    requestedLocales, localeOpt,
     44  //    %DateTimeFormat%.[[relevantExtensionKeys]], localeData).
     45  var r = ResolveLocale(
     46    "DateTimeFormat",
     47    requestedLocales,
     48    localeOpt,
     49    DateTimeFormat.relevantExtensionKeys,
     50    localeData
     51  );
     52 
     53  // 6. Let result be GetCalendarInfo(r.[[locale]]).
     54  var result = intl_GetCalendarInfo(r.locale);
     55  DefineDataProperty(result, "calendar", r.ca);
     56  DefineDataProperty(result, "locale", r.locale);
     57 
     58  // 7. Return result.
     59  return result;
     60 }