sisyphsu / dateparser

dateparser is a smart and high-performance date parser library, it supports hundreds of different formats, nearly all format that we may used. And this is also a showcase for "retree" algorithm.
MIT License
95 stars 24 forks source link

DateParser fails to parse string with UTC +13 offset #1

Closed brettgriffin closed 4 years ago

brettgriffin commented 4 years ago

This string cannot be parsed by DateParser: 2020/01/09 07:53:30 +1300

In DateParser.java, it appears the zoneoffet is bound to -720 and 720:

if (dt.zoneOffset < -720 || dt.zoneOffset > 720) {
  throw error(startOff, "Invalid ZoneOffset at " + startOff);
}

Changing this to -780 and 780 would allow the UTC+13 timestamps to be parsed.

https://en.wikipedia.org/wiki/UTC%2B13:00

sisyphsu commented 4 years ago

Thanks for your feedback~

I found this comment in jdk: the time-zone offset in hours, from -18 to +18

So the range of zoneOffset should be much bigger

sisyphsu commented 4 years ago

I have fixed this issue at new version 1.0.3, and test it.

Please try it~

brettgriffin commented 4 years ago

@sisyphsu Thanks for the quick attention to this! I just tested with 1.0.3 and it correctly parses the dates. Thanks again!

sisyphsu commented 4 years ago

Glad to help you, have a nice day~