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
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, whichPtime.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:
After: