Dual-Life / Time-Piece

Object Oriented time objects
Other
15 stars 33 forks source link

Explicit API for local strptime #44

Open Grinnz opened 5 years ago

Grinnz commented 5 years ago

Currently, to interpret a date string as localtime in strptime, you can get it to set islocal by calling it from an already local Time::Piece object:

my $time = localtime->strptime($date, $format);

It would be better if there was an explicit (and tested) way to do this, such as a third argument to strptime.

my $time = Time::Piece->strptime($date, $format, $local);
szr8 commented 4 years ago

Would $local be the time zone that ->strptime interprets $date as, and if so, if the time zone is in $date, which one should win? Or would $local just set the time zone in new object?

Grinnz commented 4 years ago

$local would just be a boolean. Time::Piece objects can only be localtime or UTC.

smith153 commented 4 years ago

Certainly noted. I've found the same issue annoying as well.

scottchiefbaker commented 4 years ago

Just to add my $0.02...

I just ran in to this strptime() bug/issue and it was not obvious how to solve it. This would be a much welcomed addition to the library.