diff --git a/src/MAT_types.jl b/src/MAT_types.jl index 1b89a64..14c90ad 100644 --- a/src/MAT_types.jl +++ b/src/MAT_types.jl @@ -494,7 +494,7 @@ end ms_to_datetime(ms::Complex) = ms_to_datetime(real(ms)) function ms_to_datetime(ms::Real) s, ms_rem = fldmod(ms, 1_000) # whole seconds and remainder milliseconds - return DateTime(1970, 1, 1) + Second(s) + Millisecond(ms_rem) + return DateTime(1970, 1, 1) + Second(s) + Millisecond(round(Int, ms_rem)) end function to_matlab_data(d::DateTime) diff --git a/test/read.jl b/test/read.jl index 08dc429..7222de4 100644 --- a/test/read.jl +++ b/test/read.jl @@ -273,6 +273,10 @@ for format in ["v7", "v7.3"] @test dt isa DateTime @test dt - DateTime(2019, 12, 2, 16, 42, 49) < Second(1) + @test "testDatetimeComplex" in keys(vars) + dtc = vars["testDatetimeComplex"] + @test dtc isa DateTime + # test no conversion at all vars = matread(filepath; convert_opaque=false)["s"] t = vars["testTable"] diff --git a/test/v7.3/struct_table_datetime.mat b/test/v7.3/struct_table_datetime.mat index 9082308..3c201c0 100644 Binary files a/test/v7.3/struct_table_datetime.mat and b/test/v7.3/struct_table_datetime.mat differ diff --git a/test/v7/struct_table_datetime.mat b/test/v7/struct_table_datetime.mat index 6a4885a..90dfa84 100644 Binary files a/test/v7/struct_table_datetime.mat and b/test/v7/struct_table_datetime.mat differ