Which calendar is used in a locale?

@return CalendarInterface
967578
public function calendar(): CalendarInterface
    {
        $non_gregorian_calendars = [
            'ar' => new ArabicCalendar(),
            'fa' => new PersianCalendar(),
            'he' => new JewishCalendar(),
            'yi' => new JewishCalendar(),
        ];

        return $non_gregorian_calendars[$this->locale->languageTag()] ?? new GregorianCalendar();
    }
844835
public function definition () {
        global $CFG, $USER;

        $mform = $this->_form;
        $userid = $USER->id;

        if (is_array($this->_customdata)) {
            if (array_key_exists('userid', $this->_customdata)) {
                $userid = $this->_customdata['userid'];
            }
        }

        // Add some extra hidden fields.
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);

        // We do not want to show this option unless there is more than one calendar type to display.
        if (count(\core_calendar\type_factory::get_list_of_calendar_types()) > 1) {
            $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
            $mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
            $mform->setType('calendartype', PARAM_ALPHANUM);
            $mform->setDefault('calendartype', $CFG->calendartype);
        } else {
            $mform->addElement('hidden', 'calendartype', $CFG->calendartype);
            $mform->setType('calendartype', PARAM_ALPHANUM);

        }

        // Date / Time settings.
        $options = array(
            '0'  => get_string('default', 'calendar'),
            CALENDAR_TF_12 => get_string('timeformat_12', 'calendar'),
            CALENDAR_TF_24 => get_string('timeformat_24', 'calendar')
        );
        $mform->addElement('select', 'timeformat', get_string('pref_timeformat', 'calendar'), $options);
        $mform->addHelpButton('timeformat', 'pref_timeformat', 'calendar');

        // First day of week.
        $options = array(
            0 => get_string('sunday', 'calendar'),
            1 => get_string('monday', 'calendar'),
            2 => get_string('tuesday', 'calendar'),
            3 => get_string('wednesday', 'calendar'),
            4 => get_string('thursday', 'calendar'),
            5 => get_string('friday', 'calendar'),
            6 => get_string('saturday', 'calendar')
        );
        $mform->addElement('select', 'startwday', get_string('pref_startwday', 'calendar'), $options);
        $mform->addHelpButton('startwday', 'pref_startwday', 'calendar');

        // Maximum events to display.
        $options = array();
        for ($i = 1; $i <= 20; $i++) {
            $options[$i] = $i;
        }
        $mform->addElement('select', 'maxevents', get_string('pref_maxevents', 'calendar'), $options);
        $mform->addHelpButton('maxevents', 'pref_maxevents', 'calendar');

        // Calendar lookahead.
        $options = array(365 => new \lang_string('numyear', '', 1),
                270 => get_string('nummonths', '', 9),
                180 => get_string('nummonths', '', 6),
                150 => get_string('nummonths', '', 5),
                120 => get_string('nummonths', '', 4),
                90  => get_string('nummonths', '', 3),
                60  => get_string('nummonths', '', 2),
                30  => get_string('nummonth', '', 1),
                21  => get_string('numweeks', '', 3),
                14  => get_string('numweeks', '', 2),
                7  => get_string('numweek', '', 1),
                6  => get_string('numdays', '', 6),
                5  => get_string('numdays', '', 5),
                4  => get_string('numdays', '', 4),
                3  => get_string('numdays', '', 3),
                2  => get_string('numdays', '', 2),
                1  => get_string('numday', '', 1));
        $mform->addElement('select', 'lookahead', get_string('pref_lookahead', 'calendar'), $options);
        $mform->addHelpButton('lookahead', 'pref_lookahead', 'calendar');

        // Remember event filtering.
        $options = array(
            0 => get_string('no'),
            1 => get_string('yes')
        );
        $mform->addElement('select', 'persistflt', get_string('pref_persistflt', 'calendar'), $options);
        $mform->addHelpButton('persistflt', 'pref_persistflt', 'calendar');
        $this->add_action_buttons(true, get_string('savechanges'));
    }
982673
private static Calendar buildCalendar() {

    Calendar calendar = calendarCache.get();
    if (calendar == null) {
      calendar = GregorianCalendar.getInstance();
      calendarCache.set(calendar);
    }
    return calendar;
  }
938749
public function searchCalendarEventAction(){
        $translator = $this->getServiceLocator()->get('translator');
        $textMessage = '';
        $request = $this->getRequest();
        // Default Values
        $id = null;

        if($request->isPost()) {

            $postValues = get_object_vars($request->getPost());

            if (!empty($postValues)){

                $calendarService = $this->getServiceLocator()->get('MelisCalendarService');
                $id = $responseData = $calendarService->deleteCalendarEvent($postValues);
            }
        }

        $response = array(
            'success' => '0',
            'textTitle' => 'tr_melistoolcalendar_delete_event_title',
            'textMessage' => $textMessage,
            'errors' => $errors,
        );

        return new JsonModel($response);
    }
1023001
public function get()
    {
        // Pre-populating the 'calendardata' is optional, if we don't have it
        // already we fetch it from the backend.
        if (!isset($this->objectData['calendardata'])) {
            $this->objectData = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $this->objectData['uri']);
        }

        return $this->objectData['calendardata'];
    }
698335
public function withDateAtStartOfWeek(string $locale = null) : self
    {
        $instance = $this->withTimeAtMidnight();
        $calendar = $instance->toIntlCalendar($locale);
        
        $calendar->set(IntlCalendar::FIELD_DOW_LOCAL, 1);
        
        $instance->date->setTimestamp((int)($calendar->getTime() / 1000));
        
        return $instance;
    }
831669
public function getLocale()
    {
        if (empty($this->locale)) {
            $this->locale = $this->getSettings()->locale->default;
        }

        return $this->locale;
    }
684300
public function getDefaultLocale()
    {
        try {
            return $this->entityManager->getRepository(Locale::class)->findOneBy(['msIsDefault' => true]);
        } catch (TableNotFoundException $e) {
            return null;
        }
    }
940284
public function getLocalizedLiteralsForLocale(Locale $locale)
    {
        if (isset($this->localizedLiterals[(string)$locale])) {
            return $this->localizedLiterals[(string)$locale];
        }

        $model = $this->cldrRepository->getModelForLocale($locale);

        $localizedLiterals['months'] = $this->parseLocalizedLiterals($model, 'month');
        $localizedLiterals['days'] = $this->parseLocalizedLiterals($model, 'day');
        $localizedLiterals['quarters'] = $this->parseLocalizedLiterals($model, 'quarter');
        $localizedLiterals['dayPeriods'] = $this->parseLocalizedLiterals($model, 'dayPeriod');
        $localizedLiterals['eras'] = $this->parseLocalizedEras($model);

        return $this->localizedLiterals[(string)$locale] = $localizedLiterals;
    }
202833
public static function getLocaleBundle()
    {
        @trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.3, use "%s" instead.', __METHOD__, Locales::class), E_USER_DEPRECATED);

        if (null === self::$localeBundle) {
            self::$localeBundle = new LocaleBundle(
                self::getDataDirectory().'/'.self::LOCALE_DIR,
                self::getEntryReader()
            );
        }

        return self::$localeBundle;
    }
1086965
public function convertToCalendar(string $calendar): AbstractCalendarDate
    {
        switch ($calendar) {
            case 'gregorian':
                return new GregorianDate($this);
            case 'julian':
                return new JulianDate($this);
            case 'jewish':
                return new JewishDate($this);
            case 'french':
                return new FrenchDate($this);
            case 'hijri':
                return new HijriDate($this);
            case 'jalali':
                return new JalaliDate($this);
            default:
                return $this;
        }
    }
801221
protected function getFormatter($options = array()) {
		$locale = empty($options['locale']) ? $this->locale : $options['locale'];
		$calendar = empty($options['calendar']) ? $this->calendar : $options['calendar'];
		$timezone = empty($options['timezone']) ? $this->getTimezone() : $options['timezone'];
		if (is_a($timezone, 'DateTimeZone')) $timezone = $timezone->getName();
		$pattern = empty($options['pattern']) ? null : $options['pattern'];
		return new \IntlDateFormatter($locale . '@calendar=' . $calendar,
				\IntlDateFormatter::FULL,  \IntlDateFormatter::FULL, $timezone,
				$calendar == 'gregorian' ? \IntlDateFormatter::GREGORIAN : \IntlDateFormatter::TRADITIONAL, $pattern);
	}
370817
public function getLocale()
    {
        $auth = $this->getView()
                     ->authentication();

        if ( $auth->hasIdentity() )
        {
            $locale = $auth->getIdentity()->locale;
        }
        else
        {
            $locale = Locale::getDefault();
        }

        return $locale;
    }
866618
function createCalendar() {
    $calendarInit1 = $calendarInit2 = $calendarxCaldecl = $calendarStart = $calendar = null;
    switch( $this->format ) {
      case 'xcal':
        $calendarInit1 = '<?xml version="1.0" encoding="UTF-8"?>'.$this->nl.
                         '<!DOCTYPE iCalendar PUBLIC "-//IETF//DTD XCAL/iCalendar XML//EN"'.$this->nl.
                         '"http://www.ietf.org/internet-drafts/draft-ietf-calsch-many-xcal-01.txt"';
        $calendarInit2 = '>'.$this->nl;
        $calendarStart = '<vcalendar';
        break;
      default:
        $calendarStart = 'BEGIN:VCALENDAR'.$this->nl;
        break;
    }
    $calendarStart .= $this->createCalscale();
    $calendarStart .= $this->createMethod();
    $calendarStart .= $this->createProdid();
    $calendarStart .= $this->createVersion();
    switch( $this->format ) {
      case 'xcal':
        $nlstrlen = strlen( $this->nl );
        if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
          $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
        $calendarStart .= '>'.$this->nl;
        break;
      default:
        break;
    }
    $calendar .= $this->createXprop();
    foreach( $this->components as $component ) {
      if( '' >= $component->getConfig( 'language'))
        $component->setConfig( 'language',  $this->getConfig( 'language' ));
      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
      $component->setConfig( 'format',      $this->getConfig( 'format' ));
      $calendar .= $component->createComponent( $this->xcaldecl );
    }
    if(( 0 < count( $this->xcaldecl )) && ( 'xcal' == $this->format )) { // xCal only
      $calendarInit1 .= $this->nl.'['.$this->nl;
      $old_xcaldecl = array();
      foreach( $this->xcaldecl as $declix => $declPart ) {
        if(( 0 < count( $old_xcaldecl)) &&
           ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
           ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
          continue; // no duplicate uri and ext. references
        $calendarxCaldecl .= '<!';
        foreach( $declPart as $declKey => $declValue ) {
          switch( $declKey ) {                    // index
            case 'xmldecl':                       // no 1
              $calendarxCaldecl .= $declValue.' ';
              break;
            case 'uri':                           // no 2
              $calendarxCaldecl .= $declValue.' ';
              $old_xcaldecl['uri'][] = $declValue;
              break;
            case 'ref':                           // no 3
              $calendarxCaldecl .= $declValue.' ';
              break;
            case 'external':                      // no 4
              $calendarxCaldecl .= '"'.$declValue.'" ';
              $old_xcaldecl['external'][] = $declValue;
              break;
            case 'type':                          // no 5
              $calendarxCaldecl .= $declValue.' ';
              break;
            case 'type2':                         // no 6
              $calendarxCaldecl .= $declValue;
              break;
          }
        }
        $calendarxCaldecl .= '>'.$this->nl;
      }
      $calendarInit2 = ']'.$calendarInit2;
    }
    switch( $this->format ) {
      case 'xcal':
        $calendar .= '</vcalendar>'.$this->nl;
        break;
      default:
        $calendar .= 'END:VCALENDAR'.$this->nl;
        break;
    }
    return $calendarInit1.$calendarxCaldecl.$calendarInit2.$calendarStart.$calendar;
  }
416316
public function reschedEventAction(){
        $translator = $this->getServiceLocator()->get('translator');
        
        $request = $this->getRequest();
        // Default Values
        $id = null;
        $status  = 0;
        $textMessage = '';
        $errors  = array();
        $textMessage = '';
        $textTitle = '';
         
        if($request->isPost()) {
             
            $postValues = get_object_vars($request->getPost());
             
            if (!empty($postValues)){
                 
                $calendarTable = $this->getServiceLocator()->get('MelisCalendarTable');
                 
                $id = $postValues['cal_id'];
                $resultEvent = $calendarTable->getEntryById($id);
                 
                if (!empty($resultEvent)){
                     
                    $event = $resultEvent->current();
                     
                    if (!empty($event)){
                         
                        $calendarService = $this->getServiceLocator()->get('MelisCalendarService');
                        $responseData = $calendarService->reschedCalendarEvent($postValues);
                        
                        if (!empty($responseData)){
                            $textMessage = 'tr_melistoolcalendar_save_event_success';
                            $status = 1;
                        }
                    }
                }
            }
        }
         
        $response = array(
            'success' => $status,
            'textTitle' => 'tr_melistoolcalendar_save_event_title',
            'textMessage' => $textMessage,
            'errors' => $errors,
        );
        
        if ($status){
            $this->getEventManager()->trigger('meliscalendar_save_event_end', $this, array_merge($response, array('typeCode' => 'CALENDAR_EVENT_DRAG', 'itemId' => $id)));
        }
         
        return new JsonModel($response);
    }
391551
function (calendar) {
            var time = calendar.getTime();
            calendar = /**@type {KISSY.Date.Gregorian}
         @ignore*/
            new GregorianCalendar(this.timezoneOffset, this.locale);
            calendar.setTime(time);
            var i, ret = [], pattern = this.pattern, len = pattern.length;
            for (i = 0; i < len; i++) {
                var comp = pattern[i];
                if (comp.text) {
                    ret.push(comp.text);
                } else if ('field' in comp) {
                    ret.push(formatField(comp.field, comp.count, this.locale, calendar));
                }
            }
            return ret.join('');
        }
360907
static DayPeriod of(
        Locale locale,
        String calendarType
    ) {

        String lang = locale.getLanguage(); // NPE-check

        if (lang.equals("nn")) {
            locale = new Locale("nb"); // CLDR 29 contains no data for language nn
        }

        Map<String, String> resourceMap = loadTextForms(locale, calendarType);
        SortedMap<PlainTime, String> codeMap = Collections.emptySortedMap();

        for (String key : resourceMap.keySet()) {
            if (accept(key)) {
                int hour = Integer.parseInt(key.substring(1, 3));
                int minute = Integer.parseInt(key.substring(3, 5));
                PlainTime time = PlainTime.midnightAtStartOfDay();
                if (hour == 24) {
                    if (minute != 0) {
                        throw new IllegalStateException("Invalid time key: " + key);
                    }
                } else if ((hour >= 0) && (hour < 24) && (minute >= 0) && (minute < 60)) {
                    time = time.plus(hour * 60 + minute, ClockUnit.MINUTES);
                } else {
                    throw new IllegalStateException("Invalid time key: " + key);
                }
                if (codeMap.isEmpty()) {
                    codeMap = new TreeMap<>();
                }
                codeMap.put(time, resourceMap.get(key));
            }
        }

        if (codeMap.isEmpty() || lang.isEmpty()) {
            return FALLBACK;
        }

        Iterator<PlainTime> iter = codeMap.keySet().iterator();
        String oldCode = "";

        while (iter.hasNext()) {
            PlainTime time = iter.next();
            String code = codeMap.get(time);
            if (code.equals(oldCode)) {
                iter.remove(); // lex colombia
            } else {
                oldCode = code;
            }
        }

        return new DayPeriod(locale, calendarType, codeMap);

    }