Skip to content

Add a UTC hardware clock checkbox to the timezone page - #89

Merged
ericbsd merged 2 commits into
masterfrom
fix-390-utc-checkbox
Aug 29, 2026
Merged

ericbsd merged 2 commits into
masterfrom
fix-390-utc-checkbox

Conversation

@ericbsd

@ericbsd ericbsd commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

The timezone page picked a zone but never said whether the hardware clock keeps UTC or local time, so the installed system fell back to whatever the live image shipped, which was local time. On a machine whose RTC keeps UTC the clock was then off by one UTC offset, and tzsetup was the only way to correct it after the install.

Add a checkbox, checked by default, that writes utcClock=yes or no for pc-sysinstall. It is written to the config whether or not a timezone was picked, so the installed system always gets an explicit answer instead of inheriting one from the image.

Resolves: ghostbsd/issues#390

Summary by Sourcery

Persist the hardware clock's UTC preference during installation so timezone configuration remains correct across systems and dual-boot setups.

New Features:

  • Add a timezone-page option to specify whether the hardware clock uses UTC, defaulting to enabled.

Bug Fixes:

  • Ensure installed systems receive an explicit hardware-clock setting instead of inheriting the live image configuration.

Chores:

  • Remove the obsolete timezone-listing backend script.

The timezone page picked a zone but never said whether the hardware
clock keeps UTC or local time, so the installed system fell back to
whatever the live image shipped, which was local time. On a machine
whose RTC keeps UTC the clock was then off by one UTC offset, and
tzsetup was the only way to correct it after the install.

Add a checkbox, checked by default, that writes utcClock=yes or no for
pc-sysinstall. It is written to the config whether or not a timezone was
picked, so the installed system always gets an explicit answer instead
of inheriting one from the image.

Resolves: ghostbsd/issues#390
@ericbsd
ericbsd requested review from a team as code owners August 25, 2026 23:32
@sourcery-ai

sourcery-ai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds a default-checked timezone-page option for indicating whether the hardware clock uses UTC, persists that choice, and always generates an explicit utcClock setting for pc-sysinstall to prevent the installed system from inheriting the live image’s local-time default.

Sequence diagram for persisting the hardware clock setting

sequenceDiagram
    participant User
    participant TimezonePage
    participant TempConfig
    participant CreateConfig
    participant PcSysinstall

    User->>TimezonePage: set utc_check
    User->>TimezonePage: save_selection()
    TimezonePage->>TempConfig: write utc_clock yes or no
    CreateConfig->>TempConfig: read utc_clock
    CreateConfig->>CreateConfig: write utcClock=yes or no
    CreateConfig->>PcSysinstall: provide generated configuration
Loading

Flow diagram for the default UTC hardware clock option

flowchart TD
    A[Open timezone page] --> B[Hardware clock uses UTC checkbox]
    B --> C[Checked by default]
    C --> D{User saves selection}
    D -->|Checked| E[Persist utc_clock=yes]
    D -->|Unchecked| F[Persist utc_clock=no]
    E --> G[Generate explicit utcClock=yes]
    F --> H[Generate explicit utcClock=no]
    G --> I[Installed system uses UTC hardware clock setting]
    H --> I
Loading

File-Level Changes

Change Details Files
Add a default-on hardware-clock mode control to the timezone UI and persist the user’s choice for installation.
  • Add a GTK checkbox with guidance for UTC versus Windows local-time RTCs.
  • Write yes/no selection to a temporary state file when saving the timezone page.
src/timezone.py
Always emit an explicit pc-sysinstall hardware-clock setting in the generated configuration.
  • Read the persisted UTC-clock state with a default of yes.
  • Write utcClock=yes or no even when no timezone was selected.
src/create_cfg.py

Assessment against linked issues

Issue Objective Addressed Explanation
ghostbsd/issues#390 Ensure the installed system uses the correct time zone and maintains correct time across reboots and power cycles. ✅
ghostbsd/issues#390 Explicitly configure whether the hardware clock uses UTC or local time instead of inheriting the live image's setting. ✅
ghostbsd/issues#390 Allow users, including dual-boot users, to select the appropriate hardware-clock behavior during installation. ✅

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/timezone.py" line_range="72-79" />
<code_context>
         time_file = open(time, 'w')
         time_file.writelines(timezone)
         time_file.close()
+        # no makes pc-sysinstall write /etc/wall_cmos_clock on the install
+        utc_file = open(utc_clock, 'w')
+        utc_file.write('yes' if self.utc_check.get_active() else 'no')
+        utc_file.close()
         return

     def __init__(self, button3):
</code_context>
<issue_to_address>
**issue (bug_risk):** When `save_selection()` is called without a continent and city selection, constructing `timezone` raises `AttributeError` before `utc_file` is opened, so no UTC-clock value is written despite the new requirement that it always be persisted.

**Triggers:** When the timezone tree has no selected continent or city.

**Suggested fix:** Write the UTC setting before constructing the timezone path, or guard missing timezone selections while still writing `yes` or `no` to `utc_clock`.

```suggestion
    def save_selection(self):
        # no makes pc-sysinstall write /etc/wall_cmos_clock on the install
        utc_file = open(utc_clock, 'w')
        utc_file.write('yes' if self.utc_check.get_active() else 'no')
        utc_file.close()
        timezone = '%s/%s' % (self.continent, self.city)
        time_file = open(time, 'w')
        time_file.writelines(timezone)
        time_file.close()
        return
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and a wrong checkbox writes an incorrect utcClock setting into the installer configuration, which can make the installed system interpret the hardware clock incorrectly and cause time shifts, especially on dual-boot machines. Reverting the change will not fix systems already installed, but the setting and resulting clock configuration are bounded and repairable.

Blocking findings: src/timezone.py:79


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/timezone.py
@ericbsd
ericbsd merged commit 0b64fd4 into master Aug 29, 2026
2 checks passed
@ericbsd
ericbsd deleted the fix-390-utc-checkbox branch August 29, 2026 16:40
@github-project-automation github-project-automation Bot moved this from In Review to Done in Development Tracker Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Location and time zone not set during install

2 participants