question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Date formatting to ISO string invalid (adding timezone computation)

See original GitHub issue

Describe 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:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
karllhughescommented, Jul 9, 2019

I’m having this same issue, but only with the atom1() method. It seems to work fine with rss2().

0reactions
brycewraycommented, Apr 18, 2022

(Perhaps) similar issue with json1() — I get an ISO string but trying to use the date triggers the item.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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ISO 8601 format a Date with Timezone Offset in ...
Here's a simple helper function that will format JS dates for you. function toIsoString(date) { var tzo = -date.getTimezoneOffset(), dif = tzo >=...
Read more >
Demystifying DateTime Manipulation in JavaScript - Toptal
We will ignore the user's time zone and use UTC while creating the date object. There are two ways to do it: Create...
Read more >
A Guide to Handling Date and Time for Full Stack JavaScript ...
We set date1 to 12 May 2021 00:00:00 UTC using the ISO 8601 format. We specify the UTC time zone using the character...
Read more >
What is the ISO date and time format? - TechTarget
The ISO 8601 standard also provides for time zone differences, as they relate to UTC. Time zone information is tagged onto the end...
Read more >
Date and Time Input / Output - Snowflake Documentation
When using AUTO date formatting, dashes and slashes are not interchangeable. Slashes imply MM/DD/YYYY format, and dashes imply YYYY-MM-DD format. Strings such ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found