← Back to Pull requests

fix(timezone): parse non-ISO strings as wall time in the target zone #3372

Open
unknown opened this pull request with 199 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 18, 2026 21:33 UTC
Author

Hi! Thanks for maintaining dayjs. I found a small bug in the timezone plugin and would love your review.

Problem (fixes #2928)

d.tz() parses every string through dayjs.utc(input, parseFormat), but UTC mode only understands ISO-like strings — anything else falls back to new Date(), which parses in the host's local time, and that timestamp is then treated as wall-clock time in the target zone. The result is off by the host offset:

dayjs.tz('01 Aug 2025').toISOString()
// with host TZ=Asia/Kolkata and default zone UTC:
// '2025-07-31T18:30:00.000Z' — should be '2025-08-01T00:00:00.000Z'
dayjs.tz('01 Aug 2025', 'Australia/Melbourne').toISOString()
// '2025-07-31T08:30:00.000Z' — should be '2025-07-31T14:00:00.000Z'

Fix

For unformatted strings without an explicit offset that fall back to the native parser, try a GMT suffix first. This keeps the host's DST rules from shifting the wall time before the target zone is applied. If the engine rejects the suffix, use the previous fallback. Strings handled by the built-in parser, explicit formats, and explicit offsets still go through dayjs.utc().

Tests

  • Added the two New York DST-gap examples from the review, plus controls for explicit offsets and expanded ISO years.

  • Timezone suite has 58 passing tests in each of America/New_York, Asia/Kolkata, Australia/Lord_Howe, and UTC. The same fall-back overlap test fails on the previous PR head.

  • Full Jest suite has 798 passing tests and the same one failure. Lint passes. Eight focused cases also pass on both Node.js and macOS JavaScriptCore.
  • Diff: 199 lines (+149 / -50) across 2 files Reviewer: Ultroncn Review duration: 17880m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 199 lines diff across 2 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.317
    Real PR Conversation Timeline
    1 comments
    "Review active on #3372"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.1% (MEDIUM) · Higher = larger blast radius
    36.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.3% · Safe to merge
    19.3%
    Repository