Skip to content

Fix #2276 - #2277

Open
kevyang08 wants to merge 1 commit into
DMOJ:masterfrom
kevyang08:master
Open

Fix #2276#2277
kevyang08 wants to merge 1 commit into
DMOJ:masterfrom
kevyang08:master

Conversation

@kevyang08

@kevyang08 kevyang08 commented Aug 23, 2023

Copy link
Copy Markdown

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

Comment thread judge/jinja2/datetime.py
@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
Copy Markdown
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.

@kevyang08 kevyang08 Aug 23, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown
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
Copy Markdown
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.

2 participants