Merge branch 'feature/gh-7' into develop
# Conflicts: # src/PhpSpreadsheet/Shared/Date.php
This commit is contained in:
commit
e0a9f9e1ec
|
@ -113,7 +113,8 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Set the Default timezone to use for dates
|
* Set the Default timezone to use for dates
|
||||||
*
|
*
|
||||||
* @param string|\DateTimeZone $timezone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
|
* @param string|\DateTimeZone $timeZone The timezone to set for all Excel datetimestamp to PHP DateTime Object conversions
|
||||||
|
* @return boolean Success or failure
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return bool Success or failure
|
* @return bool Success or failure
|
||||||
*/
|
*/
|
||||||
|
@ -145,7 +146,8 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Validate a timezone
|
* Validate a timezone
|
||||||
*
|
*
|
||||||
* @param string|\DateTimeZone $timezone The timezone to validate, either as a timezone string or object
|
* @param string|\DateTimeZone $timeZone The timezone to validate, either as a timezone string or object
|
||||||
|
* @return \DateTimeZone The timezone as a timezone object
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return \DateTimeZone The timezone as a timezone object
|
* @return \DateTimeZone The timezone as a timezone object
|
||||||
*/
|
*/
|
||||||
|
@ -162,8 +164,8 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Convert a MS serialized datetime value from Excel to a PHP Date/Time object
|
* Convert a MS serialized datetime value from Excel to a PHP Date/Time object
|
||||||
*
|
*
|
||||||
* @param int|float $dateValue MS Excel serialized date/time value
|
* @param integer|float $excelTimestamp MS Excel serialized date/time value
|
||||||
* @param \DateTimeZone|string|null $timezone The timezone to assume for the Excel timestamp,
|
* @param \DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp,
|
||||||
* if you don't want to treat it as a UTC value
|
* if you don't want to treat it as a UTC value
|
||||||
* Use the default (UST) unless you absolutely need a conversion
|
* Use the default (UST) unless you absolutely need a conversion
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
@ -201,8 +203,8 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Convert a MS serialized datetime value from Excel to a unix timestamp
|
* Convert a MS serialized datetime value from Excel to a unix timestamp
|
||||||
*
|
*
|
||||||
* @param int|float $dateValue MS Excel serialized date/time value
|
* @param integer|float $excelTimestamp MS Excel serialized date/time value
|
||||||
* @param \DateTimeZone|string|null $timezone The timezone to assume for the Excel timestamp,
|
* @param \DateTimeZone|string|null $timeZone The timezone to assume for the Excel timestamp,
|
||||||
* if you don't want to treat it as a UTC value
|
* if you don't want to treat it as a UTC value
|
||||||
* Use the default (UST) unless you absolutely need a conversion
|
* Use the default (UST) unless you absolutely need a conversion
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
@ -217,16 +219,16 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Convert a date from PHP to an MS Excel serialized date/time value
|
* Convert a date from PHP to an MS Excel serialized date/time value
|
||||||
*
|
*
|
||||||
* @param mixed $dateValue PHP serialized date/time or date object
|
* @param mixed $dateValue Unix Timestamp or PHP DateTime object or a string
|
||||||
* @return float|bool Excel date/time value
|
* @return float|boolean Excel date/time value
|
||||||
* or boolean FALSE on failure
|
* or boolean FALSE on failure
|
||||||
*/
|
*/
|
||||||
public static function PHPToExcel($dateValue = 0)
|
public static function PHPToExcel($dateValue = 0)
|
||||||
{
|
{
|
||||||
if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) {
|
if ((is_object($dateValue)) && ($dateValue instanceof \DateTimeInterface)) {
|
||||||
return self::DateTimeToExcel($dateValue);
|
return self::dateTimeToExcel($dateValue);
|
||||||
} elseif (is_numeric($dateValue)) {
|
} elseif (is_numeric($dateValue)) {
|
||||||
return self::TimestampToExcel($dateValue);
|
return self::timestampToExcel($dateValue);
|
||||||
} elseif (is_string($dateValue)) {
|
} elseif (is_string($dateValue)) {
|
||||||
return self::stringToExcel($dateValue);
|
return self::stringToExcel($dateValue);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +237,7 @@ class Date
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a DateTime object to an MS Excel serialized date/time value
|
* Convert a PHP DateTime object to an MS Excel serialized date/time value
|
||||||
*
|
*
|
||||||
* @param \DateTimeInterface $dateValue PHP DateTime object
|
* @param \DateTimeInterface $dateValue PHP DateTime object
|
||||||
* @return float MS Excel serialized date/time value
|
* @return float MS Excel serialized date/time value
|
||||||
|
@ -255,7 +257,7 @@ class Date
|
||||||
/**
|
/**
|
||||||
* Convert a Unix timestamp to an MS Excel serialized date/time value
|
* Convert a Unix timestamp to an MS Excel serialized date/time value
|
||||||
*
|
*
|
||||||
* @param \DateTimeInterface $dateValue PHP DateTime object
|
* @param \DateTimeInterface $dateValue Unix Timestamp
|
||||||
* @return float MS Excel serialized date/time value
|
* @return float MS Excel serialized date/time value
|
||||||
*/
|
*/
|
||||||
public static function timestampToExcel($dateValue = 0)
|
public static function timestampToExcel($dateValue = 0)
|
||||||
|
@ -263,8 +265,7 @@ class Date
|
||||||
if (!is_numeric($dateValue)) {
|
if (!is_numeric($dateValue)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return self::dateTimeToExcel(new \DateTime('@' . $dateValue));
|
||||||
return self::DateTimeToExcel(new \DateTime('@' . $dateValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue