Dual-Life / Time-Piece

Object Oriented time objects
Other
15 stars 33 forks source link

Check result of localtime #47

Open mattn opened 4 years ago

mattn commented 4 years ago

On Windows, localtime(1586127053815)->strftime("%Y") always crash.

smith153 commented 4 years ago

Interesting, good catch! There is quite a bit of more error checking that needs to be added to that file (currently on the TODO list). I will add this and hopefully some more checks soon.

johannessen commented 7 months ago

Another test case that apparently makes Time::Piece 1.3401 crash on Win32:

gmtime( -86400 )->strftime( '%Y-%m-%d' );

For what it’s worth, dates before 1 January 1970 are documented to fail on Win32 in Microsoft’s gmtime docs. CPAN Testers results suggest that the above correctly produces 1969-12-31 in Cygwin.

I don’t run Windows myself, but from reading this patch, it does look like it would at least avoid the crash and I think it should be merged in.