Skip to content

fix: use local time instead of UTC for session titles, log filenames, and trace timestamps#30350

Closed
v4ever1luv wants to merge 2 commits into
anomalyco:devfrom
v4ever1luv:fix/local-time-timestamps
Closed

fix: use local time instead of UTC for session titles, log filenames, and trace timestamps#30350
v4ever1luv wants to merge 2 commits into
anomalyco:devfrom
v4ever1luv:fix/local-time-timestamps

Conversation

@v4ever1luv
Copy link
Copy Markdown

@v4ever1luv v4ever1luv commented Jun 2, 2026

Issue for this PR

Closes #30347

Type of change

  • Bug fix

What does this PR do?

Replaces new Date().toISOString() calls with local-time-aware formatting in 3 files so that session titles, log filenames, and dev trace timestamps reflect the system's local timezone instead of always UTC.

Root cause: Date.prototype.toISOString() is defined by ECMAScript to always return UTC (ending with Z), ignoring TZ env var and OS timezone. For users outside UTC, this causes session titles to show incorrect times.

Changes:

  1. packages/core/src/util/log.ts — Added localStamp() and localTime() helpers that use local date components. Log filenames now use local time (e.g. 2026-06-02T070000.log), log entries show local timestamps.

  2. packages/opencode/src/session/session.ts — Added toLocalISO() that returns ISO 8601 with timezone offset. Session titles now show local time (e.g. New session - 2026-06-02T07:00:00.000+07:00). Updated isDefaultTitle regex to match both old UTC (Z) and new local (+/-HH:MM) formats for backward compatibility.

  3. packages/opencode/src/cli/cmd/run/trace.ts — Updated stamp() to use local date components; trace event times use toLocaleString() instead of toISOString().

How did you verify your code works?

  • Verified all 3 files compile within their respective packages
  • Tested regex change against both old (Z) and new (+07:00) title formats
  • Changes are purely mechanical: replace UTC-generating calls with equivalent local-time-generating calls, same output format but in local time

Screenshots / recordings

N/A — not a UI change (affects log files, session titles in database, and dev trace files)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • No issue referenced. Please add Closes #<number> linking to the relevant issue.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 2, 2026
@github-actions github-actions Bot closed this Jun 2, 2026
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.

fix: session timestamps and log filenames use UTC (toISOString()) instead of local time

1 participant