Open
Description
Describe the bug
dayjs("2013-11-18T11:55:20").tz("America/Toronto")
(as suggested in the docs) outputs the following:
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
console.log(dayjs('2013-11-18T11:55:20').tz('America/Toronto'))
// Output
{
'$L': 'en',
'$d': Invalid Date,
'$x': { '$timezone': 'America/Toronto' },
'$y': NaN,
'$M': NaN,
'$D': NaN,
'$W': NaN,
'$H': NaN,
'$m': NaN,
'$s': NaN,
'$ms': NaN,
'$offset': NaN,
'$u': false
}
Expected behavior
The following should be the output:
{
'$L': 'en',
'$d': 2013-11-18T10:55:20.000Z,
'$x': { '$localOffset': -60, '$timezone': 'America/Toronto' },
'$y': 2013,
'$M': 10,
'$D': 18,
'$W': 1,
'$H': 11,
'$m': 55,
'$s': 20,
'$ms': 0,
'$offset': -300
}
Information
- Day.js Version:
1.11.6
,1.11.0
,1.10.0
,1.9.0
(it seems like the bug is in all versions sinceutc
plugin was introduced) - OS: [e.g. iOS]: Arch Linux
- Browser [e.g. chrome 62]: n/a
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]: tested with
America/Toronto
andEurope/Slovakia
; I don’t think it matters; - Node version:
19.0.0
- NPM version:
8.19.2
Metadata
Metadata
Assignees
Labels
No labels