Parsing/formatting ISO 8601 years less than zero or greater than 9999
Not entirely sure if you should care about such years but I noticed while playing around that {parttime} doesn't always correctly parse/format ISO 8601 years less than zero or greater than 9999
According to Wikipedia years less than zero or greater than 9999 should be at least four digits wide and prependend with either a "+" or a "-" e.g.
+12345
-12345
-0004
I do observe that negative numbers strictly less than -999 seem to be formatted correctly.
Thanks for reporting. I'm a bit embarrassed to say that it never crossed my mind to test this.
Seems like it would be a reasonably straightforward fix in the regex used for ISO-8601 parsing to allow years >4 digits.
- "(?<year>[\\+-]?\\d{4}(?!\\d{2}\\b))",
+ "(?<year>[\\+-]?\\d{4,}(?!\\d{2}\\b))",
Just documenting another artifact of this behavior, printing of negative parttime years uses the - as part of the four digits. Not strictly incorrect, but makes it harder to round-trip the data as a string:
as.parttime("-0003")
## <partial_time<YMDhms+tz>[1]>
## [1] "-003"