PlaidWeb / Publ

Flexible publishing system for the web
http://publ.beesbuzz.biz/
MIT License
40 stars 4 forks source link

Dates being filtered based on server-local time #262

Open fluffy-critter opened 5 years ago

fluffy-critter commented 5 years ago

Expected Behavior

If a site is configured for e.g. UTC-7 and there's an entry posted in the native time for UTC-5, the entry visibility and relative time offset (in entry.date.humanize()) should be based on the time in UTC-5.

Current Behavior

The timestamp is interpreted as local time regardless of its declared timezone; offsets are being computed based on naive/local dates instead of utcnow.

Context

While traveling to Wisconsin, I posted an entry in UTC-5, which appeared to be 2 hours in the future and thus was treated as scheduled.

Date header:

Date: 2019-08-03 02:51:51-05:00

Entry display:

2019/08/03 2:51 AM in 2 hours

database entry:

sqlite> select utc_date,local_date,display_date from entry where id=5001;
2019-08-03 07:51:51+00:00|2019-08-03 02:51:51.000000|2019-08-03T02:51:51-05:00

This feels like a regression on an aspect which has always caused trouble in one way or another.

fluffy-critter commented 2 years ago

Experienced this again when building the submission system for novembeat.com; it seems that the Date header is always being interpreted as localtime instead of the declared timezone. It seems that arrow.get(..., tzinfo=foo) always overrides the timezone even if one is specified.

There's probably some mechanism in arrow to determine if the provided date was timezone-aware, and only overriding tzinfo if it wasn't.

fluffy-critter commented 1 month ago

Just got hit by this again while traveling across time zones. Maybe actually fix this one?