spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.97k stars 183 forks source link

String parser off by 12 hours in some cases #291

Closed Fleker closed 3 years ago

Fleker commented 3 years ago

I've been trying to use spacetime to parse some fancy date strings and have had issues with a particular format. This format is pulled from the client, which I can manually fix, but it'd be great if this case could be fixed upstream. It seems like only in this case the 'PM' string doesn't get parsed correctly if there is a space between the time and the PM.

Here are the examples of what I mean.

> spacetime('Sunday, May 30 1:00PM').toLocalDate().toString()
'Sun May 30 2021 13:00:00 GMT-0400 (Eastern Daylight Time)'
> spacetime('Sunday, May 30 1:00 PM').toLocalDate().toString()
'Sun May 30 2021 01:00:00 GMT-0400 (Eastern Daylight Time)'
> spacetime('Sunday, May 30 1:00 pm').toLocalDate().toString()
'Sun May 30 2021 01:00:00 GMT-0400 (Eastern Daylight Time)'
> spacetime('Sunday, May 30 1:00pm').toLocalDate().toString()
'Sun May 30 2021 13:00:00 GMT-0400 (Eastern Daylight Time)'
spencermountain commented 3 years ago

hey Nick, good find! Looks like a quick regex change - happy to fix this. cheers

spencermountain commented 3 years ago

fixed in v6.16.2 - cheers