57 lines
2 KiB
Diff
57 lines
2 KiB
Diff
--- a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php
|
|
+++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/OLE.php
|
|
@@ -493,42 +493,33 @@
|
|
* Utility function
|
|
* Returns a string for the OLE container with the date given.
|
|
*
|
|
- * @param int $date A timestamp
|
|
+ * @param float|int $date A timestamp
|
|
*
|
|
* @return string The string for the OLE container
|
|
*/
|
|
- public static function localDateToOLE($date)
|
|
+ public static function localDateToOLE($date): string
|
|
{
|
|
- if (!isset($date)) {
|
|
+ if (!$date) {
|
|
return "\x00\x00\x00\x00\x00\x00\x00\x00";
|
|
}
|
|
-
|
|
- // factor used for separating numbers into 4 bytes parts
|
|
- $factor = pow(2, 32);
|
|
+ $dateTime = Date::dateTimeFromTimestamp("$date");
|
|
|
|
// days from 1-1-1601 until the beggining of UNIX era
|
|
$days = 134774;
|
|
// calculate seconds
|
|
- $big_date = $days * 24 * 3600 + gmmktime(date('H', $date), date('i', $date), date('s', $date), date('m', $date), date('d', $date), date('Y', $date));
|
|
+ $big_date = $days * 24 * 3600 + (float) $dateTime->format('U');
|
|
// multiply just to make MS happy
|
|
$big_date *= 10000000;
|
|
|
|
- $high_part = floor($big_date / $factor);
|
|
- // lower 4 bytes
|
|
- $low_part = floor((($big_date / $factor) - $high_part) * $factor);
|
|
-
|
|
// Make HEX string
|
|
$res = '';
|
|
|
|
- for ($i = 0; $i < 4; ++$i) {
|
|
- $hex = $low_part % 0x100;
|
|
- $res .= pack('c', $hex);
|
|
- $low_part /= 0x100;
|
|
- }
|
|
- for ($i = 0; $i < 4; ++$i) {
|
|
- $hex = $high_part % 0x100;
|
|
- $res .= pack('c', $hex);
|
|
- $high_part /= 0x100;
|
|
+ $factor = 2 ** 56;
|
|
+ while ($factor >= 1) {
|
|
+ $hex = (int) floor($big_date / $factor);
|
|
+ $res = pack('c', $hex) . $res;
|
|
+ $big_date = fmod($big_date, $factor);
|
|
+ $factor /= 256;
|
|
}
|
|
|
|
return $res;
|