Get the date and/or time pattern
Default date pattern is short date pattern with 4 digit year.

@param int|string $datetype
@param int|string $timetype
@param int        $calendar
@return string
183390
protected function getDatePattern($datetype, $timetype, $calendar = \IntlDateFormatter::GREGORIAN)
    {
        $createPattern =
            (is_int($datetype) && $datetype !== \IntlDateFormatter::NONE) ||
            (is_int($timetype) && $timetype !== \IntlDateFormatter::NONE);
        
        $pattern = $createPattern ? $this->getDatePatternFormatter($datetype, $timetype, $calendar)->getPattern() : '';
        
        return trim(
            (is_string($datetype) ? $datetype . ' ' : '') .
            preg_replace('/\byy?\b/', 'yyyy', $pattern) .
            (is_string($timetype) ? ' ' . $timetype : '')
        );
    }
409474
public function format($datetime, $pattern, $locale = null, $timezone = null)
    {
        $date = $this->getDatetime($datetime, $timezone);

        $formatter = self::createInstance([
            'locale' => $locale ?: $this->localeDetector->getLocale(),
            'datetype' => \IntlDateFormatter::FULL,
            'timetype' => \IntlDateFormatter::FULL,
            'timezone' => $timezone ?: $this->timezoneDetector->getTimezone(),
            'calendar' => \IntlDateFormatter::GREGORIAN,
            'pattern' => $pattern,
        ]);

        return $this->process($formatter, $date);
    }
1184117
private function dateTypeBuilder(DateTimeTypeBase $type) : DateFieldBuilder
    {
        $this->type($type);

        return new DateFieldBuilder($type, $this);
    }
987560
public function addCalendarType($type, $calendarType)
	{
		if (is_string($calendarType) and !class_exists($calendarType)) {
			throw new \InvalidArgumentException("Class {$calendarType} does not exist.");
		} elseif (!in_array('Plummer\Calendarful\Calendar\CalendarInterface', class_implements($calendarType, false))) {
			throw new \InvalidArgumentException('File or File path required.');
		}

		$this->calendarTypes[$type] = is_string($calendarType) ?
			$calendarType :
			get_class($calendarType);
	}
1195180
protected function getDatePatternFormatter($datetype, $timetype, $calendar = \IntlDateFormatter::GREGORIAN)
    {
        return \IntlDateFormatter::create(
            \Locale::getDefault(),
            is_int($datetype) ? $datetype : \IntlDateFormatter::NONE,
            is_int($timetype) ? $timetype : \IntlDateFormatter::NONE,
            \IntlTimeZone::getGMT(),
            $calendar
        );
    }
300297
public function display($type = null) : string
    {
        if ($type == self::DISPLAY_DURATION) {
            return $this->diffForHumans(self::now(), true);
        }

        if (is_null($type)) {
            $type = [self::DISPLAY_SHORT, self::DISPLAY_SHORT];
        } elseif (!is_array($type)) {
            $type = [$type, $type];
        } elseif (is_array($type)) {
            if (!isset($type[1])) {
                return Calendar::formatDate($this->toMutable(), $type[0]);
            } elseif (is_null($type[0])) {
                return Calendar::formatTime($this->toMutable(), $type[1]);
            }
        }

        return Calendar::formatDatetime($this->toMutable(), implode('|', $type));
    }
877934
protected function getDatetimeFormat()
    {
        if( $this->interval !== '* * * * *' )
        {
            $interval = $this->interval.' ';
        }
        else
        {
            $interval = ( $this->minute    ?? '*' ) . ' '.
                        ( $this->hour      ?? '*' ) . ' '.
                        ( $this->dayNumber ?? '*' ) . ' '.
                        ( $this->month     ?? '*' ) . ' '.
                        ( $this->day       ?? '*' ) . ' ';
        }

        $this->defaultIntervalVariables();

        return $interval;
    }
669736
public static function getTimeAgo($timestamp = 1, $type = self::SECOND, $time = null)
    {
        if (empty($time)) {
            $time = time();
        }
        switch ($type) {
            case self::HOUR:
                $result = $time - $timestamp * 60 * 60;
                break;
            case self::MINUTE:
                $result = $time - $timestamp * 60;
                break;
            case self::SECOND:
                $result = $time - $timestamp;
                break;
            case self::YEAR:
                $result = strtotime('-' . $timestamp . ' year', $time);
                break;
            case self::MONTH:
                $result = strtotime('-' . $timestamp . ' month', $time);
                break;
            case self::DAY:
                $result = strtotime('-' . $timestamp . ' day', $time);
                break;
            case self::WEEK:
                $result = strtotime('-' . ($timestamp * 7) . ' day', $time);
                break;
            default:
                $result = $time - $timestamp;
        }
        
        return $result;
    }
396144
public function dateTime($value, $type = NULL)
    {
        $apend = "";
        switch ($type) {
            case 'time':
                    $apend = 'time';
                break;
            case 'timestamp':
                    $apend = 'timestamp';
                break;
            case 'date':
                    $apend = 'date';
                break;
            case 'datetime':
                    $apend = 'datetime';
                break;
            case 'year':
                    $apend = 'year(4)';
                break;
            default:
                    $apend = 'timestamp';
                break;
        }
        return $value . " " . $apend . " NOT NULL";
    }
1261731
protected function getDateFormat($type, $verbosity, DateTime $date)
    {
        $numWeekDay = (int)$date->format('w');
        $numWeekDay = $numWeekDay  == 0 ? 7 : $numWeekDay;
        $numMonth =  $date->format('n');

        $cacheKey = "$numWeekDay|$numMonth";

        if (isset($this->dateFormatCache[$type][$verbosity][$cacheKey])) {
            return $this->dateFormatCache[$type][$verbosity][$cacheKey];
        }

        $format = $this->getFormat($type, $verbosity);

        $format = $this->replaceDatePlaceHolders($date, $format);

        $this->dateFormatCache[$type][$verbosity][$cacheKey] = $format;

        return $format;

    }
522173
private function getWeekdays($year, $weekday, $additionalType = HolidayType::OTHER, DateTimeZone $timezone = null)
    {
        $start = new DateTime(sprintf('%s-01-01', $year), $timezone);
        $end = new DateTime(sprintf('%s-01-01', $year + 1), $timezone);
        $day = new DateTime();
        $weekdayName = Weekday::$NAME[$weekday];
        $day->setTimestamp(strtotime($weekdayName, $start->getTimestamp()));
        $holidays = [];

        while ($day->getTimestamp() < $endDate = $end->getTimestamp()) {
            $holidays[] = new Holiday($weekdayName, clone $day, HolidayType::DAY_OFF | $additionalType);
            $day->add(new DateInterval('P7D'));
        }

        return $holidays;
    }
94733
@Override
    public String getFormatPattern(
        DisplayStyle style,
        Locale locale
    ) {

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

    }
276899
public function getPHPDatePattern()
    {
        $isoFormat = Calendar::getDateFormat('short');
        $result = Calendar::tryConvertIsoToPhpFormat($isoFormat);
        if ($result === null) {
            $result = t(/*i18n: Short date format: see http://www.php.net/manual/en/function.date.php */ 'n/j/Y');
        }

        return $result;
    }
90404
public static function getConfigTypeDir(?string $type = ''): ?string
    {
        $subdir = null;
        $type = Inflector::underscore(Inflector::pluralize($type));

        if (!in_array($type, ['events', 'attendees', 'calendars'])) {
            throw new InvalidArgumentException((string)__('Wrong Config Calendar Type'));
        }

        if ('calendars' == $type) {
            $subdir = 'calendar';
        }

        if ('events' == $type) {
            $subdir = 'calendar_' . $type;
        }

        if ('attendees' == $type) {
            $subdir = 'calendar_' . $type;
        }

        return $subdir;
    }
1356612
public function date(string $format, \DateTimeZone $timeZone = null) : DateFieldBuilder
    {
        return $this->dateTypeBuilder(new DateType($format, $timeZone));
    }
273369
public static Date getTime(Datebox datebox, Timebox timebox) {
        if (timebox.getValue() == null || datebox.getValue() == null) {
            return DateUtil.stripTime(datebox.getValue());
        }

        Calendar date = Calendar.getInstance();
        Calendar time = Calendar.getInstance();
        date.setTime(datebox.getValue());
        time.setTime(timebox.getValue());
        time.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH));
        return time.getTime();
    }
1021777
public static CharSequence getJSDate(Calendar calendar)
	{
		StringBuilder dateJavascript = new StringBuilder();
		dateJavascript.append("new Date(");
		dateJavascript.append(calendar.get(Calendar.YEAR)).append(',');
		dateJavascript.append(calendar.get(Calendar.MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.DAY_OF_MONTH)).append(',');
		dateJavascript.append(calendar.get(Calendar.HOUR_OF_DAY)).append(',');
		dateJavascript.append(calendar.get(Calendar.MINUTE)).append(',');
		dateJavascript.append(calendar.get(Calendar.SECOND)).append(',');
		dateJavascript.append(calendar.get(Calendar.MILLISECOND));
		dateJavascript.append(')');

		return dateJavascript.toString();
	}