haskell / time

A time library

Home Page:http://hackage.haskell.org/package/time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

alaendle opened this issue · comments

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.

in case str of
(s : h1 : h2 : ':' : m1 : m2 : []) -> calc s h1 h2 m1 m2
(s : h1 : h2 : m1 : m2 : []) -> calc s h1 h2 m1 m2
_ -> Nothing

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

@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!

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

timeOffsetFormat doesn't match §4.2.5.1, does it?

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 zonedTimeFormat should match ISO 8601:2004(E) sec. 4.3.2 - and parsing "1985-04-12T10:15:30+04" to ZonedTimeshould be possible 😉.

Fixed.