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

Fix #2276 #2277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix #2276 #2277

wants to merge 1 commit into from

Conversation

61izzy
Copy link

@61izzy 61izzy commented Aug 23, 2023

Converts time to local time zone before assigning abs_time so that submissions display in user's selected time zone.

@@ -26,7 +27,7 @@ def wrapper(datetime, *args, **kwargs):

@registry.function
def relative_time(time, **kwargs):
abs_time = date(time, kwargs.get('format', _('N j, Y, g:i a')))
abs_time = date(time.astimezone(timezone.get_current_timezone()), kwargs.get('format', _('N j, Y, g:i a')))
Copy link
Member

Choose a reason for hiding this comment

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

Does this work when the user is logged out? Ideally, we should use the browser's timezone when they are logged out.

Copy link
Author

@61izzy 61izzy Aug 23, 2023

Choose a reason for hiding this comment

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

Yeah, seems to work when I run it locally.

Edit: Nvm, seems to use DEFAULT_USER_TIME_ZONE in settings.py

Copy link
Author

Choose a reason for hiding this comment

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

I think that might have to be fixed separately in timezone.py

Copy link
Author

Choose a reason for hiding this comment

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

Is there a way for timezone.py to access the value of Intl.DateTimeFormat().resolvedOptions().timeZone? I've tried making a few changes other in timezone.py, but nothing worked.

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

2 participants