Repository navigation
fix(sleep): prevent epoch dates on Sleep startup (#137) - #138
Open
voiceagentscc wants to merge 1 commit into
Open
voiceagentscc wants to merge 1 commit into
voiceagentscc wants to merge 1 commit into
Conversation
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.
fix(sleep): prevent epoch dates on Sleep startup (#137)
Fixes #137.
A cold start with the ring disconnected and PulseLoop on the Sleep screen can briefly show December 31, 1969 in the Day header. This PR gives the screen the correct reference-night date immediately, while stored data is still loading, and prevents zero or negative day values from reaching the header or date picker.
Cause and changes
SleepState.shownDayMillisstarts at0L. The header formats that initial value before the asynchronous database rebuild supplies the real day. Unix timestamp zero becomes December 31, 1969 in America/New_York; it can remain visible if the rebuild fails.TimeUtil.referenceNightLocal(), the same calculation used after loading.The existing reference-night rule stays consistent across startup and loading: before 4 AM local, both show yesterday; from 4 AM, both show today. Ring connection does not select the day. A date change when the clock actually crosses 4 AM remains expected.
iOS parity and related work
This restores iOS's existing behavior, following the README's guidance to keep the interfaces aligned. SleepView on iOS derives the date from the current time and passes it through
dayReferenceNight, without an initial zero timestamp. The iOS source, issues, and PRs were reviewed; the iOS app was not run to verify its behavior.Android PR #28 introduced this startup path in
0d7212c, when porting iOS PR #84's day navigation. Searches of both repositories found no duplicate report or existing fix. Android issue #107 and PR #108 addressed incorrect dates in decoded sleep history; this fix only changes the screen's initial state and date presentation.Tests
Five new
SleepDayDateTestcases cover:Long.MIN_VALUE.The initial-state, invalid-value, boundary, and historical-selection checks cover New York, UTC, and Tokyo. The daylight-saving cases use New York.
Validated from a clean worktree based on current Android
main(3f39c09), using Java 17 as CI does:The full suite passed 1,642 tests, zero failures, errors, or skips, including all five new cases and the 13 existing
TimeUtilTestcases. The debug APK built successfully. No test exclusions were needed.Device validation and limits
Debug build 77 (
2.11.0-sleep-date-pr-test-debug) was built from this PR's exact commit,2c364b9, onfix/sleep-date-zero, then installed and tested on a Samsung Galaxy A71 running Android 13.Verified on November 4, 2026:
No 1969 or 1970 date appeared in the inspected views. These checks inspected the rendered UI; they did not record its first frame before the database returned. The new initial-state regression test covers the value available during that interval.
There are no database migrations, stored-history changes, BLE protocol changes, or new public APIs.