Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timezone and sub-second in RFC822 parser. #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

paurkedal
Copy link

I noticed times from parsed feed comes out in local time without time zone. Looking at the code, this seems unintended. The issue is that passing the time-zone Ptime.to_date_time with both adjust the date and time tuples, as well as passing the time zone offset in the time tuple component, which Ptime.of_date_time uses the latter to adjust the time back to it's original value.

An easy adjustment would substitute 0 for the TZ in between the calls, but I here propose dropping the round-trip all together, as it's easy to substitute the correction into the time span used for composing the time. This also allows us to keep the sub-second precision.

Before:

utop # Syndic__Syndic_date.of_rfc822 "Sun, 19 May 2002 15:21:36 EST Sat";;
- : Ptime.t = 2002-05-19 15:21:36 +00:00

After:

utop # Syndic__Syndic_date.of_rfc822 "Sun, 19 May 2002 15:21:36 EST Sat";;
- : Ptime.t = 2002-05-19 20:21:36 +00:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant