#3030 Use timezone not offset for user activity, fix heat map
Merged by pingou. Opened by adamwill.
adamwill/pagure more-timezone-fun  into  master

Download 3030.patch

My previous attempt (in f99ac7c) still had two clear problems.
Using the current offset from UTC for the local timezone
isn't really good enough: for timezones that have daylight
savings, for instance, it'll be wrong for events that happened
in the other state (so, events that happened during daylight
savings when the query is run outside of daylight savings,
for instance).

Also, the heatmap could still be wrong, because while we now
always had the right target date in mind, we were not smart
enough about making sure we fed cal-heatmap a timestamp that
definitely fell on that date in the local timezone.

This should fix both problems. Unfortunately, we need a new JS
library to do it. Getting the actual timezone (as opposed to
the offset) is a bit tricky; it is possible to get it from many
newer browsers via the Internationalization API, but some still
do not support this, so best practice is to use a library which
takes that value if possible, but otherwise tries to figure out
the timezone by requesting the offset at various points in time
and inferring from the reported values.

We change PagureLog.date_offset() from the previous attempt to
PagureLog.date_tz(), expecting a timezone name (Olson format),
and use it much as before. To solve the heatmap issue, we try
to get 12:00 on the target date in the local timezone, and
convert that to a timestamp.

Signed-off-by: Adam Williamson awilliam@redhat.com

Note, another thing we could do here is allow the user to set their preferred timezone. The default value for all user accounts could be whatever we get from jstimezonedetect, but users could override it in their account preferences. I just didn't feel like putting all that together, though. :)

I haven't looked around for other places where we might want to consider the user's local time, either. If anyone knows of any, poke me and I can have a look.

Oh, hey, there's one: when you hover over the relative times (like "Proposed an hour ago") it shows you an absolute time that's UTC (but isn't labelled as such). It should at least be labelled as UTC, and we should probably convert it to local time...(note: github shows it in local time).

Looks fine to me, thanks for working on this! :)

Commit 8a161a97 fixes this pull-request

Pull-Request has been merged by pingou

Oh, btw, I don't know what your workflow for adding JS libraries is, so I just manually added this one in the same form as the existing ones - I did the file naming and symlink creation manually.

Metadata