Skip to content

Fix Date.toString() showing StandardName instead of DaylightName during DST - #2329

Merged
lahma merged 4 commits into
mainfrom
copilot/analyze-discussion-2328
Mar 16, 2026
Merged

lahma merged 4 commits into
mainfrom
copilot/analyze-discussion-2328

Conversation

Copilot AI commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

Date.prototype.toString() and toTimeString() always used the timezone's StandardName in the parenthetical suffix, even for dates falling within a DST period. For example, a summer date in the Eastern timezone would incorrectly show (Eastern Standard Time) instead of (Eastern Daylight Time).

Changes

  • DatePrototype.TimeZoneString(): Check TimeZoneInfo.IsDaylightSavingTime() for the specific timestamp and use DaylightName or StandardName accordingly. Dates outside the DateTimeOffset representable range (year < 0001 or > 9999) fall back to StandardName.
// Before
var tzName = " (" + _timeSystem.DefaultTimeZone.StandardName + ")";

// After
var timeZoneName = timeZone.IsDaylightSavingTime(dateTimeOffset)
    ? timeZone.DaylightName
    : timeZone.StandardName;
  • New test ToStringUsesDaylightNameWhenInDst: verifies that a summer date returns the DaylightName and a winter date returns the StandardName.
  • Updated 3 existing tests in EngineTests.cs that had incorrect hardcoded expectations — they asserted (Pacific/Eastern Standard Time) for dates that are actually in DST, masking the bug.

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

… DST periods

Co-authored-by: lahma <171892+lahma@users.noreply.github.com>
@lahma
lahma force-pushed the copilot/analyze-discussion-2328 branch from 2f051d3 to ecadcdb Compare March 16, 2026 19:41
Copilot AI and others added 2 commits March 16, 2026 19:41
…specific exception type

Co-authored-by: lahma <171892+lahma@users.noreply.github.com>
@lahma
lahma requested a review from Copilot March 16, 2026 19:41
Copilot AI changed the title [WIP] Analyze discussion to determine if a bug exists Fix Date.toString() showing StandardName instead of DaylightName during DST Mar 16, 2026
Copilot AI requested a review from lahma March 16, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Jint’s Date.prototype.toString() / toTimeString() timezone suffix to use the daylight vs. standard timezone name depending on whether the represented instant is in DST, aligning output with typical host behavior and improving correctness for summer dates.

Changes:

  • Updated DatePrototype.TimeZoneString to select DaylightName vs StandardName when the date is within the supported DateTimeOffset range.
  • Adjusted existing runtime tests to expect DST-aware timezone names (e.g., “Pacific Daylight Time” in June).
  • Added a new regression test asserting DST vs standard timezone name selection for an Eastern timezone.

Reviewed changes

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

File Description
Jint/Native/Date/DatePrototype.cs Chooses daylight vs standard timezone name when formatting timezone suffix.
Jint.Tests/Runtime/EngineTests.cs Updates expected strings to reflect DST-aware timezone naming.
Jint.Tests/Runtime/DateTests.cs Adds coverage for DST/standard name selection in toString().

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

Comment thread Jint/Native/Date/DatePrototype.cs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lahma
lahma marked this pull request as ready for review March 16, 2026 19:53
@lahma
lahma enabled auto-merge (squash) March 16, 2026 19:53
@lahma
lahma merged commit 4d73807 into main Mar 16, 2026
4 checks passed
@lahma
lahma deleted the copilot/analyze-discussion-2328 branch March 16, 2026 20:01
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.

3 participants