diff --git a/README.md b/README.md
index 1742f73..0e0de79 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# SimpleXLSXGen class 0.9.15 (Official)
+# SimpleXLSXGen class 0.9.16 (Official)
[](https://www.patreon.com/shuchkin) [](https://github.com/shuchkin/simplexlsxgen/blob/master/license.md) [](https://github.com/shuchkin/simplexlsxgen/stargazers) [](https://github.com/shuchkin/simplexlsxgen/network) [](https://github.com/shuchkin/simplexlsxgen/issues)
Export data to Excel XLSX file. PHP XLSX generator. No external tools and libraries.
@@ -40,8 +40,9 @@ $data = [
['Integer', 123],
['Float', 12.35],
['Procent', '12%'],
- ['Date','2020-05-20'],
['Datetime', '2020-05-20 02:38:00'],
+ ['Date','2020-05-20'],
+ ['Time','02:38:00'],
['String', 'See SimpleXLSXGen column autosize feature']
];
SimpleXLSXGen::fromArray( $data )->saveAs('datatypes.xlsx');
@@ -61,6 +62,7 @@ SimpleXLSXGen::fromArray( $data )->saveAs('debug.xlsx');
## History
+v0.9.16 (2020-07-29) Fixed time detection in HH:MM:SS format
v0.9.15 (2020-07-14) escape of shared strings for special chars in cells [#1](https://github.com/shuchkin/simplexlsxgen/issues/1)
v0.9.14 (2020-05-31) fixed num2name A-Z,AA-AZ column names, thx Ertan Yusufoglu
v0.9.13 (2020-05-21) if string more 160 chars, save as inlineStr
diff --git a/src/SimpleXLSXGen.php b/src/SimpleXLSXGen.php
index 8181206..46a83e4 100644
--- a/src/SimpleXLSXGen.php
+++ b/src/SimpleXLSXGen.php
@@ -357,6 +357,12 @@ class SimpleXLSXGen {
return $letter;
}
public function date2excel($year, $month, $day, $hours=0, $minutes=0, $seconds=0) {
+ $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
+
+ if ( $year === 0 ) {
+ return $excelTime;
+ }
+
// self::CALENDAR_WINDOWS_1900
$excel1900isLeapYear = True;
if (((int)$year === 1900) && ($month <= 2)) { $excel1900isLeapYear = False; }
@@ -374,8 +380,6 @@ class SimpleXLSXGen {
$decade = substr($year,2,2);
$excelDate = floor((146097 * $century) / 4) + floor((1461 * $decade) / 4) + floor((153 * $month + 2) / 5) + $day + 1721119 - $myExcelBaseDate + $excel1900isLeapYear;
- $excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
-
- return (float) $excelDate + $excelTime;
- }
+ return (float) $excelDate + $excelTime;
+ }
}