fix: add timezone selector to quiet hours in web UI - #76
Open
jampick wants to merge 1 commit into
Open
Conversation
The quiet hours section showed timezone as static read-only text
(system local only). Users had no way to choose a different timezone,
so quiet hours always fired against the Pi's local clock.
Changes:
- pi/appliance.py: add quiet_tz="" to default_config()
- pi/webapp/server.py: add SELECTABLE_TIMEZONES list; validate and
save quiet_tz from the form; pass timezones= to both render_template
calls; update _quiet_hours_active() to use configured tz via zoneinfo
- pi/webapp/templates/index.html: replace static "Timezone: {{ timezone }}"
help text with a <select> dropdown (System default + 40 IANA zones)
- printpulse/app.py: add --quiet-tz CLI argument, thread to run_watch_loop
- printpulse/watch.py: add tz param to _is_in_quiet_hours(), add
quiet_tz param to run_watch_loop(), pass tz to all call sites
- printpulse/pi_launcher.py: pass --quiet-tz from appliance config
Tests added: default_config has quiet_tz key; valid/invalid tz validation;
tz-aware quiet hours check; invalid tz falls back to local time.
Fixes #37
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<select>dropdown with 40 IANA timezone options (plus a System default entry that preserves existing behaviour)._is_in_quiet_hours()usingzoneinfo.Files changed:
pi/appliance.py—"quiet_tz": ""added todefault_config()pi/webapp/server.py—SELECTABLE_TIMEZONESlist;quiet_tzvalidation & persistence;_quiet_hours_active()is now tz-aware; bothrender_templatecalls passtimezones=pi/webapp/templates/index.html—<select name="quiet_tz">replaces the static help textprintpulse/app.py—--quiet-tzCLI argumentprintpulse/watch.py—tzparam on_is_in_quiet_hours();quiet_tzparam onrun_watch_loop()printpulse/pi_launcher.py— passes--quiet-tzfrom appliance config torun()Test plan
test_appliance.py—quiet_tzpresent in default config and defaults to""test_validation.py— valid IANA zone accepted; unknown zone rejected with error; empty string (system default) accepted; injection attempt rejectedtest_watch.py—_is_in_quiet_hourswith valid tz useszoneinfo; invalid tz falls back to local time without raisingFixes #37
🤖 Generated with Claude Code