Skip to content

[fix] Date Formatter outputs Local Time instead of UTC#33

Merged
TechQuery merged 2 commits intomasterfrom
copilot/add-timezone-offset-to-date-formatter
May 1, 2026
Merged

[fix] Date Formatter outputs Local Time instead of UTC#33
TechQuery merged 2 commits intomasterfrom
copilot/add-timezone-offset-to-date-formatter

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 1, 2026

PR-33 PR-33 PR-33 Powered by Pull Request Badge

formatDate was using Date.toJSON() which always serializes to UTC, causing formatted output to differ from the runtime's local wall-clock time.

Changes

  • source/date.ts: Shift the timestamp by getTimezoneOffset() before calling .toJSON(), so the extracted components reflect local time:
    const localDate = new Date(+date - date.getTimezoneOffset() * 60000);
    const [year, month, day, hour, minute, second, millisecond] = localDate.toJSON().split(/\D/);
  • test/date.spec.ts: Replace UTC ISO string inputs (new Date('2020-01-23T00:00:00.000Z')) with local-time constructors (new Date(2020, 0, 23)) so assertions hold in any timezone.

Human changes

  1. [fix] Time test cases
  2. [optimize] update Upstream packages

[optimize] update Upstream packages
@TechQuery TechQuery added the bug Something isn't working label May 1, 2026
@github-project-automation github-project-automation Bot moved this to In progress in Upgrade & Refactor May 1, 2026
@TechQuery TechQuery marked this pull request as ready for review May 1, 2026 03:34
Copilot AI review requested due to automatic review settings May 1, 2026 03:34
@TechQuery TechQuery changed the title fix: formatDate outputs local time instead of UTC [fix] Date Formatter outputs Local Time instead of UTC May 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates formatDate to format Date values using the runtime’s local wall-clock time (instead of UTC-derived components), and aligns project dependencies/versioning with the release.

Changes:

  • Adjust formatDate to offset the timestamp by getTimezoneOffset() before extracting ISO components.
  • Update Date formatting tests to reflect the intended local-time output.
  • Bump package version and refresh dev dependency versions (plus lockfile updates).

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
source/date.ts Shifts the Date by timezone offset so .toJSON()-extracted fields represent local time.
test/date.spec.ts Updates formatDate assertions (currently in a timezone-dependent way that needs correction).
package.json Bumps package version and updates dev dependency ranges.
pnpm-lock.yaml Updates lockfile to match dependency bumps and transitive updates.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/date.spec.ts
@TechQuery TechQuery merged commit 52d9fbe into master May 1, 2026
4 checks passed
@TechQuery TechQuery deleted the copilot/add-timezone-offset-to-date-formatter branch May 1, 2026 03:38
@github-project-automation github-project-automation Bot moved this from In progress to Done in Upgrade & Refactor May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Development

Successfully merging this pull request may close these issues.

3 participants