haskell / time

A time library
http://hackage.haskell.org/package/time
Other
119 stars 79 forks source link

According to ISO 8601:2004 § 4.3.2 something like "1985-04-12T10:15:30+04" is valid. #184

Closed alaendle closed 2 years ago

alaendle commented 3 years ago

However it seems that time zones could just be parsed in the format "±hh[:]mm".

Not sure if this counts as a bug or if my understanding of the iso norm is wrong. I just encountered this divergence while using iso8601ParseM to parse a similar string.

https://github.com/haskell/time/blob/caa9ecb3a79cf4d952d9c357ed5aa428aa4adb26/lib/Data/Time/Format/Parse/Instances.hs#L359-L362

AshleyYakeley commented 3 years ago

iso8601ParseM doesn't use that instance. Do you have a code example of incorrect behaviour?

alaendle commented 3 years ago

@AshleyYakeley - please apologize the trouble - seems I wasn't paying attention yesterday. All in all I had just the wrong expectations - I was reading ISO 8601 copied one of the first examples in the specification and wondered why I'm unable to parse the copied value into a ZonedTime 🤦‍♂️ . While https://hackage.haskell.org/package/time-1.12.1/docs/src/Data.Time.Format.ISO8601.html#line-399 clearly states that only the exact format of 'yyyy-mm-ddThh:mm:ss[.sss]±hh:mm' is supported I expected everything that is ISO 8601:2004 § 4.3.2 compliant to work (like "1985-04-12T10:15:30+04"); my second mistake was to refer the code that is responsible for unix-style parsing, and not the correct place that controls the behaviour of iso8601ParseM 🤦‍♂️ 🤦‍♂️ . Sorry again!

AshleyYakeley commented 3 years ago

I'm still not sure what is the correct behaviour tbh.

AshleyYakeley commented 3 years ago

timeOffsetFormat doesn't match §4.2.5.1, does it?

alaendle commented 3 years ago

Well, not 100% in my opinion (counterexample - "+01"); But I am not sure whether all these methods are supposed to map the complete standard at all - or whether they are only intended to support the implementation of the parsing for the "common formats". Otherwise also zonedTimeFormatshould match ISO 8601:2004(E) sec. 4.3.2 - and parsing "1985-04-12T10:15:30+04" to ZonedTimeshould be possible 😉.

AshleyYakeley commented 2 years ago

Fixed.