Skip to content

system: Fix Custom RTC Date offset calculation and UI feedback loop - #808

Open
Amnesia1000 wants to merge 1 commit into
Eglantine-Community:nx2-experimentalfrom
Amnesia1000:fix-custom-rtc-date
Open

Amnesia1000 wants to merge 1 commit into
Eglantine-Community:nx2-experimentalfrom
Amnesia1000:fix-custom-rtc-date

Conversation

@Amnesia1000

Copy link
Copy Markdown

Summary

Fixes an issue where configuring a Custom RTC Date in the UI either failed to apply or continuously reset to the current system date/time.

Root causes addressed:

  1. Settings::values.custom_rtc_offset had 64-bit limits (numeric_limits<s64>::min()/max()), which overflowed when passed to the 32-bit Qt QSpinBox and caused Qt to clamp its valid range to [0, 0]. Bounds are now bounded by int limits.
  2. The UI had a recursive feedback loop between QDateTimeEdit::dateTimeChanged and QSpinBox::valueChanged, where editing the date triggered a reset back to the current time. QSignalBlocker is now used to break this loop, and the offset is computed directly from current epoch time.
  3. In Core::System::Impl::Run, time_offset and current_time were u64, causing an underflow and overflow into future centuries when setting a date prior to the current date. They are now signed s64 with a floor of 0.
  4. Hid the redundant raw seconds QSpinBox from the configuration UI since users only need the date picker.

Type of change

  • Bug fix
  • Game compatibility / game-support
  • Performance
  • New feature
  • Refactor / cleanup
  • CI / build
  • Documentation

Related issues

Fixes #471

Testing

  • Tested on Linux
  • Tested on Windows
  • Tested on macOS
  • Tested on NVIDIA
  • Tested on AMD
  • Tested on Intel

Checklist

  • I built it locally and it compiles without new warnings
  • I did not add any copyrighted game data, keys or firmware
  • Docs updated if needed
  • I added AI Disclosure if one was used

AI Disclosure

Assisted-by: Antigravity (code analysis and review)

Fixes an issue where setting a custom RTC date either failed to apply or
reverted to the current system time:

- Clamp custom_rtc_offset bounds to 32-bit int limits so QSpinBox does
  not overflow and lock its valid range to [0, 0].
- Compute the RTC offset relative to current epoch time on edit and use
  QSignalBlocker to break the recursive signal loop between the date
  picker and spinbox.
- Handle signed offsets safely in core to avoid integer underflow on
  past dates.

Fixes Eglantine-Community#471
Assisted-by: Antigravity (code analysis and review)
@github-actions
github-actions Bot changed the base branch from nx2 to nx2-experimental November 9, 2026 15:52
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Retargeted to nx2-experimental for pre-build testing. It will be promoted to nx2 after validation.

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.

[GBug] time does not match when attempt to time travelling in pokopia

1 participant