Comment #4 on issue 118 by
makar...@gmail.com: ISO 8061 negative years (BCE)
http://code.google.com/p/noda-time/issues/detail?id=118
Jon, you are correct that negative years is an edge case. But after
entering the "pit of despair" (is this C# v Haskell Parsec), I still
believe we must address the issue in v1.
Formatting a negative year is typically NOT for human consumption. A
negative year, nearly always mean that the date is not in the current era.
So, formatters should throw if the 'y' pattern char is used and an era is
not also being formatted. When an era is also being formatted then we
always format the absolute value of the year.
The current parser that throws when a 'y' pattern encounters a negative
year is correct!
We add a new pattern char 'E', which is an ISO 8061 expansion year. An
expansion year can be negative and/or more that 4 digits. When an
expansion year is formatted at least 4 digits are used. If more then 4
digits are required then a '+' (U+002B) is prepended (in accordance with
ISO 8061) when it is positive; otherwise, a '-' (U+002D) is prepended.
On parsing, the expansion year pattern optionally allows '+' or '-' and at
least 4 digits.
The Instant Extended ISO pattern then becomes:
E'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFF'Z'. And with other ISO patterns
the "yyyy" is replaced with "E".
Have a missed anything?