parseISO with Date argument typings
See original GitHub issueI have input coming from the server as Date object but in a certain case, the server input is replaced by a JSON file with the same data. But since this is JSON, Date’s are now strings.
parseISO still appears to work with Date
as argument but the typings say the argument can only be string
.
Is this just a missing type?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
date-fns: Difference between parseISO(string) and new Date ...
Docs for parseISO here. Basically parseISO tries to parse string which holds ISO formatted date string like '2019-09-25T14:34:32.999Z' .
Read more >formatISO number of required arguments. typings vs ... - GitHub
This page says that formatISO requires only 1 argument: https://date-fns.org/v2.23.0/docs/formatISO But in the real world.
Read more >date-fns - modern JavaScript date utility library
date -fns provides the most comprehensive yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.
Read more >parseISO (JavaScript) - HCL Product Documentation
Represents a date and time. parseISO (JavaScript). Creates a Date object representing a specified time in ISO format.
Read more >client/node_modules/date-fns/CHANGELOG.md - GitLab
From now on a string should be parsed using parseISO (ISO 8601) or parse . In v1 we've used new Date() to parse...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah that’s really good to know. Seems like better standard behavior than
new Date
too.Yeah, but also
new Date
parsing algo differs from a browser to browser, so we were getting many cross-browser bug reports from people parsing loose formats (e.g.Jan 14
).Another case to use
parseISO
is when you have an incomplete string.new Date('2019-01-01')
will parse the date in UTC unlikeparseISO
that would return the date in the local timezone: