Returns an instance of Month for the given month value.

@param int $value The month number, from 1 (January) to 12 (December).

@return Month The Month instance.

@throws DateTimeException
245
public static function of(int $value) : Month
    {
        Field\MonthOfYear::check($value);

        return Month::get($value);
    }
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
244661
protected static function _getDateString($value)
    {
        $formatted = '';
        if (isset($value['year'], $value['month'], $value['day']) &&
            (is_numeric($value['year']) && is_numeric($value['month']) && is_numeric($value['day']))
        ) {
            $formatted .= sprintf('%d-%02d-%02d ', $value['year'], $value['month'], $value['day']);
        }

        if (isset($value['hour'])) {
            if (isset($value['meridian']) && (int)$value['hour'] === 12) {
                $value['hour'] = 0;
            }
            if (isset($value['meridian'])) {
                $value['hour'] = strtolower($value['meridian']) === 'am' ? $value['hour'] : $value['hour'] + 12;
            }
            $value += ['minute' => 0, 'second' => 0];
            if (is_numeric($value['hour']) && is_numeric($value['minute']) && is_numeric($value['second'])) {
                $formatted .= sprintf('%02d:%02d:%02d', $value['hour'], $value['minute'], $value['second']);
            }
        }

        return trim($formatted);
    }
204634
public function buildDateTime($value)
    {
        if ($value instanceof \DateTime) {
            return $value->format(static::DATE_TIME_FORMAT);
        } elseif (is_int($value)) {
            $date = new \DateTime();
            $date->setTimestamp($value);

            return $date->format(static::DATE_TIME_FORMAT);
        } elseif (is_string($value)) {
            $date = new \DateTime($value);

            return $date->format(static::DATE_TIME_FORMAT);
        }
        throw new \InvalidArgumentException('DateTime value should be int, string or \DateTime');
    }
84423
protected function Add( $value )
	{
		switch ( $value->GetValueCode() )
		{
			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var YearMonthDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, $this->_value->Value, ! $this->_value->IsLocal );
				return new DateTimeProxy( DateTimeValue::AddYearMonthDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add(  $this->_value, /* YearMonthDurationValue */ $value->getValue() ) );

			case DayTimeDurationProxyFactory::Code:
				/**
				 * @var DayTimeDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, clone $this->_value->Value );
				return new DateTimeProxy( DateTimeValue::AddDayTimeDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add(  $this->_value, /* DayTimeDurationValue*/ $value->getValue() ) );

			default:
				throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:add",
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $this->_value), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}
54188
private function toDateTimeImmutable(?DateTimeInterface $value): ?DateTimeImmutable
    {
        if (true === $value instanceof DateTime) {
            $value = DateTimeImmutable::createFromMutable($value);
        }

        return $value;
    }
786262
public static function fromValue($value) : Type
    {
        switch (gettype($value)) {
            case 'string':
                return Text::long();

            case 'integer':
                return Integer::big();

            case 'double':
                return new Decimal(30, 15);

            case 'boolean':
                return new Boolean();

            case $value instanceof \DateTimeInterface:
                return new DateTime();

            default:
                throw InvalidArgumentException::format(
                        'Invalid call to %s: unknown value type \'%s\' given',
                        __METHOD__, gettype($value)
                );
        }
    }
78318
protected function getMonths()
    {
        $intSecondsPerMonth = ($this->isPositive()) ? DateTimeSpan::SECONDS_PER_MONTH : ((-1) * DateTimeSpan::SECONDS_PER_MONTH);
        $intMonths = floor($this->intSeconds / $intSecondsPerMonth);
        if ($this->isNegative()) {
            $intMonths = (-1) * $intMonths;
        }
        return $intMonths;
    }
1058060
public function dayOfMonth($value): self
    {
        $value = \is_array($value) ? $value : \func_get_args();

        return $this->spliceIntoPosition(3, \implode(',', $value));
    }
719584
protected function asDateTime($value)
    {
        if ($value instanceof Carbon) {
            return $value->timezone($this->getTimezone());
        }

        if ($value instanceof \DateTimeInterface) {
            return new Carbon(
                $value->format('Y-m-d H:i:s.u'),
                $value->getTimezone()
            );
        }

        if (is_numeric($value)) {
            return Carbon::createFromTimestamp($value)->timezone($this->getTimezone());
        }

        return Carbon::createFromFormat($this->getFormat(), $value);
    }
1101272
public function convertToPHPValue($value, AbstractPlatform $platform) : ?DateTime
    {
        if ($value === null || $value instanceof DateTime) {

            return $value;
        }

        if ( ! $this->getUtc() instanceof DateTimeZone) {

            $this->setUtc(new DateTimeZone('UTC'));
        }

        /** @var DateTime $converted */
        $converted = DateTime::createFromFormat(
            $platform->getDateTimeFormatString(),
            $value,
            $this->getUtc()
        );

        if ( ! $converted) {
            throw ConversionException::conversionFailedFormat(
                $value,
                $this->getName(),
                $platform->getDateTimeFormatString()
            );
        }

        return $converted;
    }
209737
public function setTimezone($value)
    {
        /** @var static $date */
        $date = parent::setTimezone(static::safeCreateDateTimeZone($value));
        // https://bugs.php.net/bug.php?id=72338
        // just workaround on this bug
        $date->getTimestamp();

        return $date;
    }
927064
public function createDateTime($value)
    {
        $date = null;

        if(is_string($value)) {
            $date = new \DateTime($value);
        }

        if(is_int($value)) {
            $date = new \DateTime();
            $date->setTimestamp($value);
        }

        return $date;
    }
277550
public function retrieveMonth($month) {
		if (!$month) {
			return 0;
		}
		$month = mb_strtolower($month);
		if (in_array($month, $this->monthList)) {
			$keys = array_keys($this->monthList, $month);
			return $keys[0] + 1;
		}
		return 0;
	}
536743
public static function VALUE($value = '')
    {
        $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);

        if (!is_numeric($value)) {
            $numberValue = str_replace(
                PHPExcel_Shared_String::getThousandsSeparator(),
                '',
                trim($value, " \t\n\r\0\x0B" . PHPExcel_Shared_String::getCurrencyCode())
            );
            if (is_numeric($numberValue)) {
                return (float) $numberValue;
            }

            $dateSetting = PHPExcel_Calculation_Functions::getReturnDateType();
            PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);

            if (strpos($value, ':') !== false) {
                $timeValue = PHPExcel_Calculation_DateTime::TIMEVALUE($value);
                if ($timeValue !== PHPExcel_Calculation_Functions::VALUE()) {
                    PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                    return $timeValue;
                }
            }
            $dateValue = PHPExcel_Calculation_DateTime::DATEVALUE($value);
            if ($dateValue !== PHPExcel_Calculation_Functions::VALUE()) {
                PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);
                return $dateValue;
            }
            PHPExcel_Calculation_Functions::setReturnDateType($dateSetting);

            return PHPExcel_Calculation_Functions::VALUE();
        }
        return (float) $value;
    }
1110005
public function prepareValue($value)
    {
        $date = Carbon::createFromFormat($this->format, $value);

        return $date->year * 12 + ($date->month - 1);
    }
1143812
protected function Sub($value)
	{
		switch ( $value->GetValueCode() )
		{
			case DateTimeProxyFactory::Code:
				return new DayTimeDurationProxy( DateTimeValue::Sub( $this->_value, /* DateTimeValue */ $value->getValue() ) );

			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var DayTimeDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, clone $this->_value->Value, ! $this->_value->IsLocal );
				$value->getValue()->Value->invert = ! $value->getValue()->Value->invert;
				return new DateTimeProxy( DateTimeValue::AddYearMonthDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add( $this->_value, - /* YearMonthDurationValue */ $value->getValue() ) );

			case DayTimeDurationProxyFactory::Code:
				/**
				 * @var DayTimeDurationProxy $value
				 */
				// Clone the DateValue contained in the proxy or the original is changed
				$clone = DateTimeValue::fromDate( $this->_value->S, clone $this->_value->Value, ! $this->_value->IsLocal );
				$value->getValue()->Value->invert = ! $value->getValue()->Value->invert;
				return new DateTimeProxy( DateTimeValue::AddDayTimeDuration( $clone, $value->getValue() ) );
				// return new DateTimeProxy( DateTimeValue::Add( $this->_value, - /* DayTimeDurationValue */ $value->getValue() ) );

			default:
				throw XPath2Exception::withErrorCodeAndParams("XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:sub",
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $this->_value), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}