/*
Use a custom locale for compact calendar and reinitialise the view.
549855
public void setLocale(TimeZone timeZone, Locale locale){
        compactCalendarController.setLocale(timeZone, locale);
        invalidate();
    }
1267487
private static Calendar getInstanceInternal(TimeZone tz, ULocale locale) {
        if (locale == null) {
            locale = ULocale.getDefault(Category.FORMAT);
        }
        if (tz == null) {
            tz = TimeZone.getDefault();
        }

        Calendar cal = createInstance(locale);
        cal.setTimeZone(tz);
        cal.setTimeInMillis(System.currentTimeMillis());
        return cal;
    }
1121156
public static void setCalendarData(Calendar calendar, Locale locale)
    {
        int[] array = (int[])localeData.get(locale);
        if(array == null)
        {
            Calendar c = Calendar.getInstance(locale);
            array = new int[2];
            array[0] = c.getFirstDayOfWeek();
            array[1] = c.getMinimalDaysInFirstWeek();
            localeData.putIfAbsent(locale, array);
        }
        calendar.setFirstDayOfWeek(array[0]);
        calendar.setMinimalDaysInFirstWeek(array[1]);
    }
866199
public static final <T extends Calendar> Function<T, LocalDate> calendarToLocalDate(DateTimeZone dateTimeZone) {
		return new CalendarToLocalDate<T>(dateTimeZone);
	}
1167876
private void updateCalendarVisibility() {
		CalendarView view = getSkinnable();

		if (view.getSelectedPage() == view.getDayPage()) {
			view.getDayPage().refreshData();
		} else if (view.getSelectedPage() == view.getWeekPage()) {
			view.getWeekPage().refreshData();
		}
	}
277430
function generateLocaleExtra(locale, localeData) {
  const dayPeriods = getDayPeriodsNoAmPm(localeData);
  const dayPeriodRules = getDayPeriodRules(localeData);

  let dayPeriodsSupplemental = [];

  if (Object.keys(dayPeriods.format.narrow).length) {
    const keys = Object.keys(dayPeriods.format.narrow);

    if (keys.length !== Object.keys(dayPeriodRules).length) {
      throw new Error(`Error: locale ${locale} has not the correct number of day period rules`);
    }

    const dayPeriodsFormat = removeDuplicates([
      objectValues(dayPeriods.format.narrow),
      objectValues(dayPeriods.format.abbreviated),
      objectValues(dayPeriods.format.wide)
    ]);

    const dayPeriodsStandalone = removeDuplicates([
      objectValues(dayPeriods['stand-alone'].narrow),
      objectValues(dayPeriods['stand-alone'].abbreviated),
      objectValues(dayPeriods['stand-alone'].wide)
    ]);

    const rules = keys.map(key => dayPeriodRules[key]);

    dayPeriodsSupplemental = [...removeDuplicates([dayPeriodsFormat, dayPeriodsStandalone]), rules];
  }

  return `${HEADER}
const u = undefined;

export default ${stringify(dayPeriodsSupplemental).replace(/undefined/g, 'u')};
`;
}
115772
void synchronizeCurrentLocale() {

        m_basePanel.clear();
        destroyForm(false);
        CmsEntity entity = m_entityBackend.getEntity(m_entityId);
        m_entityId = getIdForLocale(m_locale);
        ((CmsDefaultWidgetService)getWidgetService()).setSkipPaths(Collections.<String> emptyList());
        loadDefinition(m_entityId, entity, new I_CmsSimpleCallback<CmsContentDefinition>() {

            public void execute(CmsContentDefinition contentDefinition) {

                setContentDefinition(contentDefinition);
                renderFormContent();
                setChanged();
            }
        });
    }
1012576
function() {
			var aArguments = Array.prototype.slice.call(arguments),
				sCalendar, sKey;
			// Calendar data needs special handling, as CustomLocaleData does have one version of calendar data only
			if (aArguments[0].indexOf("ca-") == 0) {
				sCalendar = aArguments[0];
				if (sCalendar == getCLDRCalendarName()) {
					aArguments = aArguments.slice(1);
				}
			}

			sKey = aArguments.join("-");
			// first try customdata with special formatted key
			// afterwards try customdata lookup
			// afterwards try mData lookup
			var vValue = this.mCustomData[sKey];
			if (vValue == null) {
				vValue = this._getDeep(this.mCustomData, arguments);
				if (vValue == null) {
					vValue = this._getDeep(this.mData, arguments);
				}
			}

			return vValue;
		}
44011
public Calendar toCalendar(T dateTime, Locale locale) {
    return toDateTime(dateTime).toCalendar(locale);
  }
998300
function createLocalization(defaultLocale, availableLangs, resIds, name) {
  // This function is called by `Localization` class to retrieve an array of
  // `ResourceBundle`s.
  function requestBundles(requestedLangs = navigator.languages) {
    const newLangs = negotiateLanguages(
      requestedLangs, availableLangs, { defaultLocale }
    );

    const bundles = newLangs.map(
      lang => new ResourceBundle(lang, resIds)
    );

    return Promise.resolve(bundles);
  }

  if (name === 'main') {
    document.l10n = new DocumentLocalization(requestBundles, createContext);
    document.l10n.ready = documentReady().then(() => {
      document.l10n.connectRoot(document.documentElement);
      return document.l10n.translateDocument();
    }).then(() => {
      window.addEventListener('languagechange', document.l10n);
    });
  } else {
    // Pass the main Localization, `document.l10n`, as the observer.
    const l10n = new DOMLocalization(
      requestBundles, createContext, name, document.l10n
    );
    // Add this Localization as a delegate of the main one.
    document.l10n.delegates.set(name, l10n);
  }
}
197238
public void setLocale(Locale locale)
   {
      List<SimpleDateFormat> formats = new ArrayList<SimpleDateFormat>();
      for (SimpleDateFormat format : m_formats)
      {
         formats.add(new SimpleDateFormat(format.toPattern(), locale));
      }

      m_formats = formats.toArray(new SimpleDateFormat[formats.size()]);
   }
203919
private void init(final Calendar definingCalendar) {
		patterns = new ArrayList<>();

		final StrategyParser fm = new StrategyParser(definingCalendar);
		for (;;) {
			final StrategyAndWidth field = fm.getNextStrategy();
			if (field == null) {
				break;
			}
			patterns.add(field);
		}
	}
1073415
private void initializeData(ULocale locale)
    {
        String key = locale.toString();
        DateIntervalInfo dii = DIICACHE.get(key);
        if ( dii == null ) {
            // initialize data from scratch
            setup(locale);
            // Marking fIntervalPatterns read-only makes cloning cheaper.
            fIntervalPatternsReadOnly = true;
            // We freeze what goes in the cache without freezing this object.
            DIICACHE.put(key, ((DateIntervalInfo) clone()).freeze());
        } else {
            initializeFromReadOnlyPatterns(dii);
        }
    }
1350491
public void init(String strDateParam, Date dateTarget, String strLanguage)
    {
        if (strDateParam != null)
            dateParam = strDateParam;      // Property name
        initComponents();
        this.setName("JCalendarPopup");

        nowDate = new Date();
        if (dateTarget == null)
            dateTarget = nowDate;
        selectedDate = dateTarget;

        if (strLanguage != null)
        {
            Locale locale = new Locale(strLanguage, "");
            if (locale != null)
            {
                calendar = Calendar.getInstance(locale);
                dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
            }
        }
        calendar.setTime(dateTarget);
        calendar.set(Calendar.HOUR_OF_DAY, 12);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        targetDate = calendar.getTime();
        this.layoutCalendar(targetDate);
        if (dateTarget == nowDate)
            selectedDate = targetDate;  // If they want a default date, make the time 12:00
    }
581729
function formatDate(lang, input) {

	var result = input;
	var matches;
	var localeDateString;

	while ((matches = DATE_REGEX.exec(input)) != null) {

		var date = new Date(Date.parse(matches[1]));
		var format = matches[2] != undefined ? matches[2].toLowerCase() : "compact";

		if (format != "compact") {
			localeDateString = date.toLocaleDateString(lang,
				{
					day: "numeric",
					weekday: format,
					month: format,
					year: "numeric"
				});
		}
		else {
			localeDateString = date.toLocaleDateString();
		}
		result = result.replace(matches[0], localeDateString);
	};
	return result;

}
832081
public static final <T extends Calendar> Function<T, LocalTime> calendarToLocalTime(DateTimeZone dateTimeZone) {
		return new CalendarToLocalTime<T>(dateTimeZone);
	}
518836
function onShow(superOnShow) {
  superOnShow();
  
	changeCalendar.call(this, "en", calendarTypes.GREGORIAN, sample, 2);
  
  this.calendar.setSelectedDate({"month":11,"year":2017,"day":1});
	var fn = this.calendar.nextMonth.bind(this.calendar);
	
	// runner.add(fn, "nextMonth");
	// runner.add(fn, "nextMonth2");
	// runner.add(fn, "nextMonth3");
	// runner.add(fn, "nextMonth4");
	// runner.add(fn, "nextMonth5");
	// runner.add(fn, "nextMonth6");
	// runner.add(fn, "nextMonth7");
	// runner.add(fn, "nextMonth8");
	// runner.add(fn, "nextMonth9");
	// runner.add(fn, "nextMonth10");
	
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth5");
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth6");
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth7");
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth8");
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth9");
	// runner.add(this.calendar.nextMonth.bind(this.calendar), "nextMonth10");
	
	// runner.add(this.calendar.prevMonth.bind(this.calendar), "prevMonth");
	// runner.add(this.calendar.prevMonth.bind(this.calendar), "prevMonth2");
	// runner.add(this.calendar.prevMonth.bind(this.calendar), "prevMonth3");

	// setTimeout(function(){
		runner.runAll(3, function(res){
			res.forEach(function(item, index){
				// console.log(index+":"+item.logs.length);
				console.log(index+":"+item.asString);
				// item.logs.forEach(function(log){
				// });
			});
		});
		
	// }
	// , 3)
  // alert(JSON.stringify(benchmark()))
  // console.log(benchmark());
}