Intl.DateTimeFormat does not output same results on different machines
Asked Answered
V

1

10

we have a weird behavior of Intl.DateTimeFormat in our tests (but same in Node or chrome console).

This function :

Intl.DateTimeFormat('en-AU', { year: 'numeric', month: 'short', day: 'numeric' }).format(new Date());

will return month day, year for the CI or my coworkers on mac and linux machines (english language setup).

But it will return day month year on my machine (mac, english language setup).

Example for today it will return Jan 13, 2021 for some and 13 Jan 2021 for others, even though we are relying on the same locale. And it's consistent on machines, results will be the same with jest run, node console or browser console.

Any idea what could cause that ?

Volt answered 13/1, 2021 at 5:17 Comment(0)
E
0

Had same issue. I was able to get same result as in CI/other machines by switching terminal where I was running the command. In my case VS Code terminal was printing incorrectly and iTerm/Mac Terminal worked correctly.

Elastic answered 3/1, 2023 at 22:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.