Returns a parser for a month-day such as `12-31`.

@return PatternParser
559397
public static function monthDay() : PatternParser
    {
        static $parser;

        if ($parser) {
            return $parser;
        }

        return $parser = (new PatternParserBuilder())
            ->appendLiteral('--')
            ->appendCapturePattern(MonthOfYear::PATTERN, MonthOfYear::NAME)
            ->appendLiteral('-')
            ->appendCapturePattern(DayOfMonth::PATTERN, DayOfMonth::NAME)
            ->toParser();
    }
1023389
static public function parse($value, $pattern = 'MM/dd/yyyy', $defaults = [])
    {
        if (null === self::$_mbstringAvailable) {
            self::$_mbstringAvailable = extension_loaded('mbstring');
        }
        $ps = self::analysisPattern($pattern);
        $i = 0;
        $n = self::$_mbstringAvailable ? mb_strlen($value, APP_CHARSET) : strlen($value);
        foreach ($ps as $p) {
            switch ($p) {
                case 'yyyy':
                    {
                        if (false === ($year = self::parseInteger($value, $i, 4, 4)))
                            return false;
                        $i += 4;
                        break;
                    }
                case 'yy':
                    {
                        if (false === ($year = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($year);
                        break;
                    }
                case 'MM':
                    {
                        if (false === ($month = self::parseInteger($value, $i, 2, 2)))
                            return false;
                        $i += 2;
                        break;
                    }
                case 'M':
                    {
                        if (false === ($month = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($month);
                        break;
                    }
                case 'dd':
                    {
                        if (false === ($day = self::parseInteger($value, $i, 2, 2)))
                            return false;
                        $i += 2;
                        break;
                    }
                case 'd':
                    {
                        if (false === ($day = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($day);
                        break;
                    }
                case 'h':
                case 'H':
                    {
                        if (false === ($hour = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($hour);
                        break;
                    }
                case 'hh':
                case 'HH':
                    {
                        if (false === ($hour = self::parseInteger($value, $i, 2, 2)))
                            return false;
                        $i += 2;
                        break;
                    }
                case 'm':
                    {
                        if (false === ($minute = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($minute);
                        break;
                    }
                case 'mm':
                    {
                        if (false === ($minute = self::parseInteger($value, $i, 2, 2)))
                            return false;
                        $i += 2;
                        break;
                    }
                case 's':
                    {
                        if (false === ($second = self::parseInteger($value, $i, 1, 2)))
                            return false;
                        $i += strlen($second);
                        break;
                    }
                case 'ss':
                    {
                        if (false === ($second = self::parseInteger($value, $i, 2, 2)))
                            return false;
                        $i += 2;
                        break;
                    }
                case 'a':
                    {
                        if (false === ($ampm = self::parseAmPm($value, $i)))
                            return false;
                        if (isset($hour)) {
                            if ($hour == 12 && $ampm === 'am')
                                $hour = 0;
                            else if ($hour < 12 && $ampm === 'pm')
                                $hour += 12;
                        }
                        $i += 2;
                        break;
                    }
                default:
                    {
                        $tn = self::$_mbstringAvailable ? mb_strlen($p, APP_CHARSET) : strlen($p);
                        if ($i >= $n || ($p{0} != '?' && (self::$_mbstringAvailable ? mb_substr($value, $i, $tn, APP_CHARSET) : substr($value, $i, $tn)) !== $p))
                            return false;
                        $i += $tn;
                        break;
                    }
            }
        }
        if ($i < $n)
            return false;

        if (!isset($year))
            $year = isset($defaults['year']) ? $defaults['year'] : date('Y');
        if (!isset($month))
            $month = isset($defaults['month']) ? $defaults['month'] : date('n');
        if (!isset($day))
            $day = isset($defaults['day']) ? $defaults['day'] : date('j');
        if (strlen($year) === 2) {
            $year = Unit::getFullYear($year);
        }
        $year = (int)$year;
        $month = (int)$month;
        $day = (int)$day;

        if (
            !isset($hour) && !isset($minute)
            && !isset($second) && !isset($defaults['hour'])
            && !isset($defaults['minute']) && !isset($defaults['second'])
        ) {
            $hour = $minute = $second = 0;
        } else {
            if (!isset($hour)) {
                $hour = isset($defaults['hour']) ? $defaults['hour'] : date('H');
            }
            if (!isset($minute)) {
                $minute = isset($defaults['minute']) ? $defaults['minute'] : date('i');
            }
            if (!isset($second)) {
                $second = isset($defaults['second']) ? $defaults['second'] : date('s');
            }
            $hour = (int)$hour;
            $minute = (int)$minute;
            $second = (int)$second;
        }

        if (Unit::isValidDate($year, $month, $day) && Unit::isValidTime($hour, $minute, $second)) {
            return Unit::getTimestamp($hour, $minute, $second, $month, $day, $year);
        }
        return false;
    }
853036
protected List<Rule> parsePattern() {
		final DateFormatSymbols symbols = new DateFormatSymbols(locale);
		final List<Rule> rules = new ArrayList<>();

		final String[] ERAs = symbols.getEras();
		final String[] months = symbols.getMonths();
		final String[] shortMonths = symbols.getShortMonths();
		final String[] weekdays = symbols.getWeekdays();
		final String[] shortWeekdays = symbols.getShortWeekdays();
		final String[] AmPmStrings = symbols.getAmPmStrings();

		final int length = pattern.length();
		final int[] indexRef = new int[1];

		for (int i = 0; i < length; i++) {
			indexRef[0] = i;
			final String token = parseToken(pattern, indexRef);
			i = indexRef[0];

			final int tokenLen = token.length();
			if (tokenLen == 0) {
				break;
			}

			Rule rule;
			final char c = token.charAt(0);

			switch (c) {
				case 'G': // era designator (text)
					rule = new TextField(Calendar.ERA, ERAs);
					break;
				case 'y': // year (number)
				case 'Y': // week year
					if (tokenLen == 2) {
						rule = TwoDigitYearField.INSTANCE;
					} else {
						rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen);
					}
					if (c == 'Y') {
						rule = new WeekYear((NumberRule) rule);
					}
					break;
				case 'M': // month in year (text and number)
					if (tokenLen >= 4) {
						rule = new TextField(Calendar.MONTH, months);
					} else if (tokenLen == 3) {
						rule = new TextField(Calendar.MONTH, shortMonths);
					} else if (tokenLen == 2) {
						rule = TwoDigitMonthField.INSTANCE;
					} else {
						rule = UnpaddedMonthField.INSTANCE;
					}
					break;
				case 'd': // day in month (number)
					rule = selectNumberRule(Calendar.DAY_OF_MONTH, tokenLen);
					break;
				case 'h': // hour in am/pm (number, 1..12)
					rule = new TwelveHourField(selectNumberRule(Calendar.HOUR, tokenLen));
					break;
				case 'H': // hour in day (number, 0..23)
					rule = selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen);
					break;
				case 'm': // minute in hour (number)
					rule = selectNumberRule(Calendar.MINUTE, tokenLen);
					break;
				case 's': // second in minute (number)
					rule = selectNumberRule(Calendar.SECOND, tokenLen);
					break;
				case 'S': // millisecond (number)
					rule = selectNumberRule(Calendar.MILLISECOND, tokenLen);
					break;
				case 'E': // day in week (text)
					rule = new TextField(Calendar.DAY_OF_WEEK, tokenLen < 4 ? shortWeekdays : weekdays);
					break;
				case 'u': // day in week (number)
					rule = new DayInWeekField(selectNumberRule(Calendar.DAY_OF_WEEK, tokenLen));
					break;
				case 'D': // day in year (number)
					rule = selectNumberRule(Calendar.DAY_OF_YEAR, tokenLen);
					break;
				case 'F': // day of week in month (number)
					rule = selectNumberRule(Calendar.DAY_OF_WEEK_IN_MONTH, tokenLen);
					break;
				case 'w': // week in year (number)
					rule = selectNumberRule(Calendar.WEEK_OF_YEAR, tokenLen);
					break;
				case 'W': // week in month (number)
					rule = selectNumberRule(Calendar.WEEK_OF_MONTH, tokenLen);
					break;
				case 'a': // am/pm marker (text)
					rule = new TextField(Calendar.AM_PM, AmPmStrings);
					break;
				case 'k': // hour in day (1..24)
					rule = new TwentyFourHourField(selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen));
					break;
				case 'K': // hour in am/pm (0..11)
					rule = selectNumberRule(Calendar.HOUR, tokenLen);
					break;
				case 'X': // ISO 8601
					rule = Iso8601_Rule.getRule(tokenLen);
					break;
				case 'z': // time zone (text)
					if (tokenLen >= 4) {
						rule = new TimeZoneNameRule(timeZone, locale, TimeZone.LONG);
					} else {
						rule = new TimeZoneNameRule(timeZone, locale, TimeZone.SHORT);
					}
					break;
				case 'Z': // time zone (value)
					if (tokenLen == 1) {
						rule = TimeZoneNumberRule.INSTANCE_NO_COLON;
					} else if (tokenLen == 2) {
						rule = Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES;
					} else {
						rule = TimeZoneNumberRule.INSTANCE_COLON;
					}
					break;
				case '\'': // literal text
					final String sub = token.substring(1);
					if (sub.length() == 1) {
						rule = new CharacterLiteral(sub.charAt(0));
					} else {
						rule = new StringLiteral(sub);
					}
					break;
				default:
					throw new IllegalArgumentException("Illegal pattern component: " + token);
			}

			rules.add(rule);
		}

		return rules;
	}
564431
static String getIntervalPattern(ChronoParser<?> parser) {

        AttributeQuery attrs = parser.getAttributes();

        if (attrs.contains(Attributes.LANGUAGE)) {
            Locale locale = attrs.get(Attributes.LANGUAGE);
            return CalendarText.patternForInterval(locale);
        }

        return "{0}/{1}";

    }
1231150
public static MonthDay parse(String str, DateTimeFormatter formatter) {
        LocalDate date = formatter.parseLocalDate(str);
        return new MonthDay(date.getMonthOfYear(), date.getDayOfMonth());
    }
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);

    }
822371
protected function parsePattern($pattern)
    {
        $parts = [
            'min' => '[0-5]?\d',
            'hour' => '[01]?\d|2[0-3]',
            'day' => '0?[1-9]|[12]\d|3[01]',
            'month' => '[1-9]|1[012]',
            'dow' => '[0-7]',
            'year' => '20([0-9]{2})',
        ];

        $regex = [];
        foreach (array_slice($parts, 0, 5) as $name => $number) {
            $range = '('.$number.')(-('.$number.'))?';
            $regex[$name] = '(?P<'.$name.'>(\*(\/\d+)?|'.$range.'(,'.$range.')*))';
        }
        $range = '('.$parts['year'].')(-('.$parts['year'].'))?';
        $regexYear = '( (?P<year>(\*(\/\d+)?|'.$range.'(,'.$range.')*)))?';

        $regex = '/^'.implode('([\s\t]+)', $regex).$regexYear.'$/';
        preg_match($regex, $pattern, $matches);

        return array_intersect_key($matches, $parts);
    }
497934
private int parseMonth(String month) {
    for (int i = 0; i < months.length; i++)
      if (months[i].startsWith(month))
        return i;
    return -1;
  }
513105
public PeriodFormatter getPeriodFormatter() {
    if (formatter == null) {
      formatter = ps.newPeriodFormatterFactory()
          .setLocale(localeName)
          .getFormatter();
    }
    return formatter;
  }
1283938
public function getOptionParser() {
		$parser = parent::getOptionParser();

		$parser->addSubcommands([
			CAKE_LDAP_SHELL_CRON_TASK_SYNC => [
					'help' => __d('cake_ldap', 'Sync information of employees with LDAP server'),
					'parser' => $this->Sync->getOptionParser()
			]]);

		return $parser;
	}
808834
def replace_month_abbr_with_num(date_str, lang=DEFAULT_DATE_LANG):
    """"""
    num, abbr = get_month_from_date_str(date_str, lang)
    return re.sub(abbr, str(num), date_str, flags=re.IGNORECASE)
432520
private Calendar getSortCalendar() {
        if (sortDate == null) {
            final DateParser parser = new DateParser(getDate());
            sortDate = parser.getSortCalendar();
        }
        return sortDate;
    }
1364477
public function getExpForPeriod()
    {
        $value = 'SUBSTR(`' . self::AS_BON_BASE_PERIOD . '`.`' . EPeriod::A_DSTAMP_BEGIN . '`, 1, 6)';
        $result = new \Praxigento\Core\App\Repo\Query\Expression($value);
        return $result;
    }
367904
public function getMonths() {
        $months = array();
        for ($i = 1; $i <= 12; $i++) {
            if ($i < 10)
                $months[$i] = '0' . $i;
            else
                $months[$i] = $i;
        }
        return $months;
    }
373479
private static DateTimeFormatter getSafeDateTimeFormatter(final String pattern) {
		DateTimeFormatter safeFormatter = getDateTimeFormatter(pattern);

		if (Locale.UK.equals(safeFormatter.getLocale())) {
			return safeFormatter.withLocale(Locale.ENGLISH);
		}

		return safeFormatter;
	}
676980
public function toString()
    {
        $translator = call_user_func([$this->dateClass, 'getTranslator']);

        $parts = [];

        $format = !$this->startDate->isStartOfDay() || $this->endDate && !$this->endDate->isStartOfDay()
            ? 'Y-m-d H:i:s'
            : 'Y-m-d';

        if ($this->recurrences !== null) {
            $parts[] = $this->translate('period_recurrences', [], $this->recurrences, $translator);
        }

        $parts[] = $this->translate('period_interval', [':interval' => $this->dateInterval->forHumans([
            'join' => true,
        ])], null, $translator);

        $parts[] = $this->translate('period_start_date', [':date' => $this->startDate->rawFormat($format)], null, $translator);

        if ($this->endDate !== null) {
            $parts[] = $this->translate('period_end_date', [':date' => $this->endDate->rawFormat($format)], null, $translator);
        }

        $result = implode(' ', $parts);

        return mb_strtoupper(mb_substr($result, 0, 1)).mb_substr($result, 1);
    }
94733
@Override
    public String getFormatPattern(
        DisplayStyle style,
        Locale locale
    ) {

        return GenericDatePatterns.get("chinese", style, locale); // always redirect to chinese calendar

    }