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

Change page date/times to display in local time based on style timezone setting #3503

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chiizujin
Copy link
Contributor

@chiizujin chiizujin commented Apr 12, 2024

Brief overview of PR changes/additions

The page command currently shows page date/times in UTC. This changes the date/times to the local time zone based on the setting in style.

Motivation for adding to Evennia

Show local time for pages.

Other info

UTC:

>page
Your latest pages:
 14:07:52 to Chiizujin:> Test.
 14:07:52 from Chiizujin:< Test.

Local time:

>page
Your latest pages:
 00:07:52 to Chiizujin:> Test.
 00:07:52 from Chiizujin:< Test.

Copy link
Member

@Griatch Griatch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't think this is correct. While the default time zone for the server is UTC, it doesn't have to be. This is configured by the settings.TIME_ZONE setting. If this is changed, I'm pretty sure the Msg objects (page.date_created) will be set in that time zone, and then this solution will be wrong.

What should be done here is instead to convert from the server TIME_ZONE (also if it's not UTC) to the player's time zone.

@chiizujin
Copy link
Contributor Author

chiizujin commented Apr 28, 2024

When looking at the value of page.date_created, the messages always seem to have the time in UTC, no matter what the server's time zone setting is at the time of creation. I may be missing some other piece of the puzzle somewhere, but that's why I did a conversion from UTC to the style timezone setting.

However, I think the better solution is to convert the time to the local time zone if the two time zones aren't the same, whch is probably how I should have done it in the first place. This way it doesn't matter what the time zones of the server or page.date_created are; it gets converted if it's not the requested one. I've committed a change to do this. I'll do the same in the mail PR if you're OK with this solution.

Here's an example of the UTC times in the messages (this is with the current behaviour):

>py evennia.settings.TIME_ZONE
Australia/Sydney

>page me TEST 1
Account Chiizujin pages: TEST 1
You paged Chiizujin with: 'TEST 1'.

>page
Your latest pages:
 03:22:50 to Chiizujin:> TEST 1
 03:22:50 from Chiizujin:< TEST 1

page.date_created:

2024-04-28 03:22:50.823627+00:00
2024-04-28 03:22:50.823627+00:00
>py evennia.settings.TIME_ZONE
US/Central

>page me TEST 2
Account Chiizujin pages: TEST 2
You paged Chiizujin with: 'TEST 2'.

>page
Your latest pages:
 03:24:43 to Chiizujin:> TEST 2
 03:24:43 from Chiizujin:< TEST 2

page.date_created:

2024-04-28 03:24:43.674000+00:00
2024-04-28 03:24:43.674000+00:00

For context, the UTC time according to https://www.timeanddate.com/worldclock/timezone/utc was:
03:26:03 UTC

I'm not sure if this is related, but django.utils.timezone.now() always returns a UTC time, regardless of the server's time zone setting.

@InspectorCaracal
Copy link
Contributor

So, I discovered something interesting while poking at this, and I believe the current timezone settings are actually bugged. 😆 I'm going to file an issue since it got a bit complicated but I'll reference it here.

@chiizujin
Copy link
Contributor Author

OK, I'll park this and #3504 until you've go that sorted.

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.

None yet

3 participants