Date formatting to ISO string invalid (adding timezone computation)
See original GitHub issueDescribe the bug
When you create a date from an iso8601 string, and when you try to “render” it, e.g. with date.toISOString()
(source: lib/atom.1.js:67
),
it computes it and works with the time-zone.
I’m in a case in which I want to have absolutely 0 change from the original timestamp, but the JS conversion removes 2 hours from the actual timestamp on render.
Wouldn’t it be possible for “updated” to take an iso-formatted string, either validating it or trusting the developer to not fuck up the format ?
To Reproduce Steps to reproduce the behavior:
Tested in UTC+2 time zone
new Date("2018/09/09")
// Returns Date 2018-09-08T22:00:00.000Z
Expected behavior
I’d expect it to return Date 2018-09-09T00:00:00.000Z
More informations
The obtained error is:
TypeError: Cannot read property 'toISOString' of undefined
index.js:36
at /home/nyx/git/Blog/node_modules/feed/lib/atom1.js:67:34
Because, since I pass a correctly-formatted ISO string and not a Date instance, the validator doesn’t take the value, so it evaluates to undefined
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
I’m having this same issue, but only with the
atom1()
method. It seems to work fine withrss2()
.(Perhaps) similar issue with
json1()
— I get an ISO string but trying to use the date triggers theitem.date.toISOString is not a function
error. What’s getting returned is, for example,2022-04-06T14:55:00.000Z
.Disregard. Figured it out. My apologies. Thanks for
feed
!