Skip to content

Intl.DateTimeFormat wrong locale #26860

Answered by al-cheb
vasco3 asked this question in Actions
Discussion options

You must be logged in to vote

Hello, @vasco3
I can reproduce the issue with Node 12 which one set up by default. The official distribution of Node 14 includes ‘full icu’: the locale database. Without that data Node only supports ‘en-US’ and will throw for other languages, and silently fall back to ‘en-US’ for English with other countries.

jobs:
  build:
    runs-on: ubuntu-latest
steps:
  - uses: actions/setup-node@v2-beta
    with:
      node-version: '14'
  - name: node
    run: |
      cat <<EOF > test.js
      const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); 
      console.log(new Intl.DateTimeFormat('es-MX').format(date));  
      console.log(new Date(date).toLocaleString('es-MX', {weekday:'long'}…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants