-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adds Time info to message feed header #192
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## neater_ui #192 +/- ##
==========================================
Coverage 80.16% 80.16%
==========================================
Files 28 28
Lines 353 353
==========================================
Hits 283 283
Misses 70 70 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a clarification for my own benefit.
var offsetHours = Math.abs(offset / 60); | ||
var offsetSign = offset <= 0 ? '+' : '-'; | ||
var offsetString = offsetSign + String(offsetHours).padStart(2, '0') | ||
timezoneElement.textContent = timezone + ' (UTC' + offsetString + ')'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My JS knowledge is non-existent, so just to confirm I get this right, this line here will update the HTML element below with id="timezone"
giving it the value TIMEZONE (UTC + OFFSET_HOURS)
, both TIMEZONE and OFFSET calculated here, right?
I'd add h
to the string. Not sure if standard, but makes it clearer.
timezoneElement.textContent = timezone + ' (UTC' + offsetString + ')'; | |
timezoneElement.textContent = timezone + ' (UTC' + offsetString + 'h)'; |
Also, there are some fractional timezones which I'm not sure if will be handled properly with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly it will update the element with that ID.
I did not take into account the fractional timezones will amend this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Diego Alonso Álvarez <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this needs to use a different approach. Message timestamps are rendered according to the django TIME_ZONE
setting i.e. a fixed timezore for all users. This implementation will dynamically detect the users current timezone rather than the timezone configured on the server. As this setting is only available on the server the rendering should be performed an the server side within the template.
I followed these docs to get the server time https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#std:templatefilter-time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Needs a little visual tweak I think. Maybe it could be shown as a small grey line of text above the search bar - "All timestamps are displayed in ...".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks @Sahil590
Description
uses JavaScript to get the timezone info and displays if in the message feed header.
Fixes #159 (issue)
Type of change
Key checklist
python -m pytest
)python -m sphinx -b html docs docs/build
)pre-commit run --all-files
)Further checks