You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using pendulum==2.0.3 and I want to return an RFC-1123 compliant date in the HTTP response headers as defined here: HTTP-date
The date is formatted like this (today's date): Mon, 27 Aug 2018 02:13:09 +0000
Now I will feed that date back into my code and Pendulum should parse it, but instead throws an exception:
pendulum.parsing.exceptions.ParserError: Unable to parse string [Mon, 27 Aug 2018 02:13:09 +0000]
According to the documentation which I shared the link above, the date should be formatted something like this:
Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
How come Pendulum produces a date format which it can't parse itself?
And is there proper support for RFC 1123 and RFC 822 in Pendulum or do I need to use something else?
Thank you for the tips. I chose the second approach and that seems to be working.
But for my first question, I am still not sure. The referred specification about HTTP-date says that the timezone should be GMT whereas Pendulum returns +0000.
Mon, 27 Aug 2018 02:13:09 +0000
Is it possible that Pendulumn returns GMT in place of +0000 to be compliant with the standards of rfc1123-date and rfc850-date?
There is a strong trend towards the use of numeric timezone
indicators, and implementations SHOULD use numeric timezones
instead of timezone names. However, all implementations MUST
accept either notation. If timezone names are used, they MUST
be exactly as defined in RFC-822.
So what Pendulum is doing is correct and the recommended way.
I did not say Pendulum is wrong, and I agree with the above quoted citation. But still, for rfc1123 and rfc850 dates it should not be numerical but fixed GMT instead of +0000.
Currently, I simply replace it manually after I converted the date with Pendulum, but it would be nice if Pendulum would do it according to rfc1123 and rfc850 by default.
Activity
sdispater commentedon Aug 28, 2018
You can take two approaches here. You can either use the
from_format()helper:or use the
parse()method in non-strict mode:trancee commentedon Aug 29, 2018
Thank you for the tips. I chose the second approach and that seems to be working.
But for my first question, I am still not sure. The referred specification about HTTP-date says that the timezone should be GMT whereas Pendulum returns +0000.
Is it possible that Pendulumn returns GMT in place of +0000 to be compliant with the standards of rfc1123-date and rfc850-date?
sdispater commentedon Sep 24, 2018
From what I read in the RFC it says:
So what Pendulum is doing is correct and the recommended way.
trancee commentedon Sep 24, 2018
I did not say Pendulum is wrong, and I agree with the above quoted citation. But still, for rfc1123 and rfc850 dates it should not be numerical but fixed GMT instead of +0000.
Currently, I simply replace it manually after I converted the date with Pendulum, but it would be nice if Pendulum would do it according to rfc1123 and rfc850 by default.