Skip to content

fix(console): show prefs-page times in the browser's timezone - #219

Merged
bryangingechen merged 1 commit into
masterfrom
fix/console-prefs-timezone
Oct 22, 2026
Merged

bryangingechen merged 1 commit into
masterfrom
fix/console-prefs-timezone

Conversation

@bryangingechen

@bryangingechen bryangingechen commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

A reviewer reported that the "Preferences saved at" time on the console prefs page was two hours behind (they're on CEST).

The prefs view picked a zone on the server (Zulip's zone, then core.User.timezone, then UTC) and validated the form inside timezone.override(), but rendered the template after leaving it. Django converts aware datetimes to the zone active at render time, so the page showed UTC times under the reviewer's zone name. away_until had the same problem with a worse effect: it was shown in UTC but read back in the reviewer's zone, so saving the form unchanged moved it earlier by the zone's UTC offset. Existing away_until values for reviewers outside UTC may already have drifted, and the data doesn't show which ones.

Rather than just moving the render, this switches the page to the browser's zone, as the rest of the console and the bot's Zulip messages already use. The server renders times in its default zone and the form posts back, in a hidden timezone field, the zone they are in. prefs_form.js rewrites each away_until from its stored instant into the browser's zone and sets that field to match, so the server always reads a time in the zone it was shown in. A posted zone the server can't load saves nothing and shows an error, rather than misreading the times. The "saved at" time is a <time> element, converted in the browser like other console timestamps. Without JS the page stays in the server's zone and says so.

This removes zulip_bot.services.user_timezone, which had no other caller, along with its Zulip API call on every page load, and updates design doc 022 and the console and zulip_bot AGENTS.md files. core.User.timezone is now read by nothing; dropping the column is listed as a follow-up in doc 022.

Tested: new tests in console/tests/test_prefs.py and zulip_bot/frontend/tests/prefs_form.test.js. The console, core and zulip_bot suites pass against the Compose Postgres, as do manage.py check, makemigrations --dry-run --check, vitest and ruff.

🤖 Generated with Claude Code

@bryangingechen bryangingechen changed the title fix(console): render the prefs page in the reviewer's timezone fix(console): show prefs-page times in the browser's timezone Oct 22, 2026
A reviewer on CEST saw the prefs page's "Preferences saved at" time two
hours behind. The view resolved a zone on the server (Zulip's zone, then
core.User.timezone, then UTC) and validated the form inside
timezone.override(), but rendered the template after leaving it. Django
converts aware datetimes to the zone active at render time, so the page
showed UTC times under the reviewer's zone name. away_until was shown in
UTC but read back in the reviewer's zone, so saving the form unchanged
moved it earlier by that zone's UTC offset.

The prefs page was also the only reviewer-facing surface that picked a
zone on the server; the rest of the console and the bot's Zulip messages
show times in the reader's own zone. So instead of only moving the render,
use the browser's zone here too. The server renders times in its default
zone, and the form posts back the zone they are in, in a hidden `timezone`
field. prefs_form.js rewrites each away_until from its stored instant
(data-utc) into the browser's zone and sets that field to match, so the
server always reads a time in the zone it was shown in. Rendering stays
inside the override. A posted zone the server cannot load saves nothing
rather than misreading the times. The "saved at" time is a <time> element,
localized by console/base.html like the rest of the console.

Removes zulip_bot.services.user_timezone, which has no other caller, and
with it a Zulip API call per render. Updates design doc 022 and the
console/zulip_bot AGENTS.md files. core.User.timezone is now unread;
dropping it is left as a follow-up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryangingechen
bryangingechen force-pushed the fix/console-prefs-timezone branch from 6ab7a7d to 1247614 Compare October 22, 2026 15:55
@bryangingechen
bryangingechen merged commit fc8d7bf into master Oct 22, 2026
8 checks passed
@bryangingechen
bryangingechen deleted the fix/console-prefs-timezone branch October 22, 2026 16:03
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.

1 participant