Time Zone Problem In Postorius
I have the server TZ set to EST. I have the TZ for Postfix set to EST. I have the following set in my settings_local.py file:
TIME_ZONE = 'America/New_York' USE_TZ = True
However messages showing up in the pending moderation queue box shows UTC date. I am seeing this behavior in Affinity as well so I figured it is either a Mailman core setting or perhaps database? Can anyone shed light on that?
Brian
On Thu, May 28, 2020, at 2:02 PM, Brian Carpenter wrote:
I have the server TZ set to EST. I have the TZ for Postfix set to EST. I have the following set in my settings_local.py file:
TIME_ZONE = 'America/New_York' USE_TZ = True
However messages showing up in the pending moderation queue box shows UTC date. I am seeing this behavior in Affinity as well so I figured it is either a Mailman core setting or perhaps database? Can anyone shed light on that?
I think that's because we display as-is values in the UI. Core really doesn't need to be aware of the TZ related info IMO, it is the responsibility of UI (Django!) to record the user's/UIs preferred timezone info and use that with the datetime objects.
The offending line1 for held messages is this, which simply formats the datetime to a specific "format" but we need to also format it to localtime using perhaps 2. There would be similar values for other places where date time objects are presented in the UI.
The change is simple enough, if you can open a ticket, it should be simple enough to fix I think.
Brian
Mailman-users mailing list -- mailman-users@mailman3.org To unsubscribe send an email to mailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
-- thanks, Abhilash Raj (maxking)
I notice that the template was updated to add the code. However, I still observe an issue.
If the correct hold date is: 2022-01-13 10:16 GMT+8 or 2022-01-13 02:16 GMT If I select my time zone as Asia/Hong_Kong, it is displayed as Jan. 13, 2022, 2:16 a.m. If I select time zone as GMT, it is displayed as Jan. 12, 2022, 6:16 p.m.
There is a shift of -8 hours when displaying the time in Postorius. I cannot find the detail of the held message from database tables yet. Not sure how the hold date was stored at this moment.
The hold date is stored as follow when retrieved using API:
hold_date: 2022-01-13T02:16:05.069795
On 1/12/22 7:34 PM, Alan So wrote:
I notice that the template was updated to add the code. However, I still observe an issue.
If the correct hold date is: 2022-01-13 10:16 GMT+8 or 2022-01-13 02:16 GMT If I select my time zone as Asia/Hong_Kong, it is displayed as Jan. 13, 2022, 2:16 a.m. If I select time zone as GMT, it is displayed as Jan. 12, 2022, 6:16 p.m.
There is a shift of -8 hours when displaying the time in Postorius. I cannot find the detail of the held message from database tables yet. Not sure how the hold date was stored at this moment.
As you note later, the hold time is stored in UTC. It should be rendered in Postorius held message view in the timezone that you have set in your user-profile. The timezone conversion is in Django. It is defined in the template as
{{ msg.hold_date|datetime_parse|localtime|date:"DATETIME_FORMAT"}}
where msg.hold_date is the time in UTC. I think the issue is that while msg.hold_date in in UTC, it is a naive datetime.datetime object (see https://docs.djangoproject.com/en/4.0/topics/i18n/timezones/#interpretation-...) so if your Django setting for TIME_ZONE is Asia/Hong_Kong it is interpreted as UTC +0800 so that subtracts 8 hours and then conversion to your profile timezone if Asia/Hong_Kong adds 8 hours back.
I think if you set TIME_ZONE = 'UTC'
you will get the behavior you expect.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Thanks. You are correct. Things become normal when I change TIME_ZONE back to 'UTC'. It looks like it is the only way to have this held message part to work correctly at this moment. As I notice that the archive of this message is also showing the time in UTC to me when I mouse over on the time even I select Asia/Hong_Kong in my profile. But when I mouse over to yours, it shows 9:11pm.
The TIME_ZONE setting only had an effect in my log file, if that helps. It was bugging me that the hyperkitty logs were always in UTC but mailman's log times were in my local time zone.
participants (5)
-
Abhilash Raj
-
Alan So
-
alexs@ecoscentric.com
-
Brian Carpenter
-
Mark Sapiro