Skip to content

Intl.DateFormat changes output between Node 16.16 and Node 16.17 #44454

Closed
@rmehner

Description

@rmehner

Version

v16.17.0

Platform

Darwin 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

Given this script:

const assert = require("node:assert/strict")

const date = new Date("2022-03-16T14:25:38")
const options = { day: "2-digit", month: "long", hour: "2-digit", minute: "2-digit" }
const formatted = new Intl.DateTimeFormat("en", options).format(date)

assert.strictEqual(formatted, "March 16, 02:25 PM")

Run with Node 16.16 will run just fine, with Node 16.17 it will throw:

node:assert:124
  throw new AssertionError(obj);
  ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'March 16 at 02:25 PM'
- 'March 16, 02:25 PM'
           ^
    at Object.<anonymous> (script.js:7:8)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: 'March 16 at 02:25 PM',
  expected: 'March 16, 02:25 PM',
  operator: 'strictEqual'
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

March 16, 02:25 PM

What do you see instead?

March 16 at 02:25 PM

Additional information

I suspect that #42655 introduced the change. And I guess it's fine, since current browsers I've checked actually produce the same output as 16.17, so this issue is likely just documentation for people who stumble into this :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    icuIssues and PRs related to the ICU dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions