File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ use std::convert::From;
3
3
use calamine:: DataType ;
4
4
use pyo3:: prelude:: * ;
5
5
6
+ /// https://learn.microsoft.com/en-us/office/troubleshoot/excel/1900-and-1904-date-system
7
+ static EXCEL_1900_1904_DIFF : f64 = 1462.0 ;
8
+
6
9
#[ derive( Debug ) ]
7
10
pub enum CellValue {
8
11
Int ( i64 ) ,
@@ -39,7 +42,9 @@ impl From<&DataType> for CellValue {
39
42
DataType :: Float ( v) => CellValue :: Float ( v. to_owned ( ) ) ,
40
43
DataType :: String ( v) => CellValue :: String ( String :: from ( v) ) ,
41
44
DataType :: DateTime ( v) => {
42
- if v < & 1.0 {
45
+ // FIXME: need to fix after fixing in calamine
46
+ if v < & 1.0 || ( * v - EXCEL_1900_1904_DIFF < 1.0 && * v - EXCEL_1900_1904_DIFF > 0.0 )
47
+ {
43
48
value. as_time ( ) . map ( CellValue :: Time )
44
49
} else if * v == ( * v as u64 ) as f64 {
45
50
value. as_date ( ) . map ( CellValue :: Date )
You can’t perform that action at this time.
0 commit comments