- changed status to wontfix
Dates with negative sign tz offset "-00:00" cause "Negative ISO 8601 time offset must not be 0."
Issue #30
wontfix
I have searched and find no reference to this issue. With I find strange..
I have to read some dates from XML files, and if I try to read a date like
2021-01-27T22:07:16-00:00
I will get a error “aniso8601.exceptions.ISOFormatError: Negative ISO 8601 time offset must not be 0.
”
If I change it to +00:00 it’s cool.
This looks like a bug to me.
Example code
import aniso8601
d_str1 = '2021-01-27T22:07:16+00:00'
read_date = aniso8601.parse_datetime(d_str1)
print(f'{read_date}')
d_str2 = '2021-01-27T22:07:16-00:00'
read_date = aniso8601.parse_datetime(d_str2) <--- ERROR
print(f'{read_date}')
Comments (1)
-
repo owner - Log in to comment
From 4.2.5.1 of ISO 8601:2004(E) (caution PDF link): "It [the difference between local time and UTC] shall be expressed as positive (i.e. with the leading plus sign [+]) if the local time is ahead of or equal to UTC of day and as negative (i.e. with the leading minus sign [-]) if it is behind UTC of day."
So, as the error says, negative offset is not allowed by ISO 8601. Perhaps your dates are actually encoded in RFC 3339?