Replace Chronos timing with sovereign pulse#65
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /** Convenience: set offset so that "sun rose now". */ | ||
| export function tapSunroseNow(now = new Date()) { | ||
| const utcMid = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())); | ||
| // Date gives ms resolution; fine for an *offset*. | ||
| const sec = new Decimal(now.getTime() - utcMid.getTime()).div(1000); | ||
| setSunriseOffsetSec(sec); | ||
| export function tapSunroseNow() { | ||
| setSunriseOffsetSec(0); | ||
| } |
There was a problem hiding this comment.
Fix tapSunroseNow to record actual sunrise time
tapSunroseNow now always calls setSunriseOffsetSec(0), so pressing “sun rose now” anchors sunrise to UTC midnight instead of the current wall time. Users who rely on this control will shift the solar window and all solar-aligned counters (e.g., muSolarWindowDaily, getSolarAlignedCounters) by up to a full day away from the real sunrise.
Useful? React with 👍 / 👎.
| const frac = m[4] ? new Decimal("0." + m[4]) : new Decimal(0); | ||
|
|
||
| const localMid = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0, 0); | ||
| const localCandidate = new Date(localMid.getTime()); | ||
| localCandidate.setHours(hh, mm, ss, 0); | ||
|
|
||
| const candidateMs = new Decimal(localCandidate.getTime()).plus(frac.mul(1000)); | ||
| const utcMid = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())); | ||
| const offsetSec = candidateMs.minus(utcMid.getTime()).div(1000); | ||
| const offsetSec = new Decimal(hh * 3600 + mm * 60 + ss).plus(frac); | ||
| setSunriseOffsetSec(offsetSec); |
There was a problem hiding this comment.
Restore timezone conversion in setSunriseFromLocalHHMM
setSunriseFromLocalHHMM now computes offsetSec directly from the HH:MM[:SS] string without converting the local wall time to UTC. In any non-UTC timezone this stores the local clock value as seconds since UTC midnight, off by the timezone offset, so daily anchors and solar counters will be shifted by several hours whenever a user enters their local sunrise time.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task