hosseinmoein / DataFrame

C++ DataFrame for statistical, Financial, and ML analysis -- in modern C++ using native types and contiguous memory storage
https://hosseinmoein.github.io/DataFrame/
BSD 3-Clause "New" or "Revised" License
2.38k stars 298 forks source link

DateTime: Issue with parsing ISO datetime #255

Closed Oggy16 closed 10 months ago

Oggy16 commented 10 months ago

Hello,

I have come across this issue when reading in a stream of ISO timestamps:

Caught exception:DateTime::DateTime(const char *): Don't know how to parse '2018-12-21 13:07:44+00'

Having a look at my data source, this does come out as a valid timestamp:

 2018-12-21 13:07:35.980351+00 
 2018-12-21 13:07:40.882764+00 
 2018-12-21 13:07:41.736225+00 
 2018-12-21 13:07:44+00        
 2018-12-21 13:07:44.875975+00 
 2018-12-21 13:07:45.837165+00 
 2018-12-21 13:07:46.785412+00 

What I think has happened is luck has provided me with an entry in the DB that was precisely 2018-12-21 13:07:44 and 0 milliseconds. In this case it represents it without ".0", which causes the above issue.

However the DateTime.pdf indicates that it should support "YYYY-MM-DD HH:MM:SS" format as well as the "YYYY-MM-DD HH:MM:SS.MMM" format, so I thought I'd raise this ticket to see what is going on.

hosseinmoein commented 10 months ago

will take a look

hosseinmoein commented 10 months ago

can you copy/paste the line of code that gives you the error?

hosseinmoein commented 10 months ago

The problem is not that it doesn't have .0. It is the +00 notation that confuses the parser

hosseinmoein commented 10 months ago

This has been fixed in master

Oggy16 commented 10 months ago

Wow, thanks for looking into this so fast, I didn't even have time to respond and provide example code!

I've just pulled from latest master, rebuilt and am testing.

I originally thought the "+00" was the issue, as it was not defined in the DateTime PDF, but what threw me is the fact it seemed to work if there were milliseconds defined.

Oggy16 commented 10 months ago

Looks like your fix has resolved my issue, thank you very much! :-) I will close the ticket as resolved.