Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing methods from "date-fns" #479

Closed
hazem3500 opened this issue Oct 4, 2020 · 6 comments · Fixed by #578
Closed

Missing methods from "date-fns" #479

hazem3500 opened this issue Oct 4, 2020 · 6 comments · Fixed by #578
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@hazem3500
Copy link

hazem3500 commented Oct 4, 2020

I was using "date-fns" and wanted to move to use "date-io" interface but I found a couple of methods that I am using are missing.

Methods

I know that some of these methods can be achieved by using other methods in the current interface but am not sure how to handle the ones that aren't.
I am not sure if adding these methods to the interface is the best option since it will increase the API surface, what do you guys suggest for these kinds of situations?

@dmtrKovalenko
Copy link
Owner

Hey, thanks for raising this. My question – how you are planning to use date-io? If this really required I can add these methods – it's not a problem.

sub* methods will not be added in favor of negative number addMonth(date, -12)

@dmtrKovalenko dmtrKovalenko added the enhancement New feature or request label Oct 5, 2020
@hazem3500
Copy link
Author

@dmtrKovalenko I am forking react-datepicker and trying to make it agnostic of the date-management library so it can support additional calendar systems.

I ended up creating the above functions using the available functions from date-io, it would be great if someone of them were added though.

@dmtrKovalenko
Copy link
Owner

dmtrKovalenko commented Oct 5, 2020

Awesome! I will add all the required functions, but probably except the

  • isDate - makes no sense in cross-lib comparison
  • parseISO – ISO strings perfectly parses using new Date() or utils.date()

Give me a few days to make a PR and new version

@dmtrKovalenko dmtrKovalenko added the good first issue Good for newcomers label Oct 8, 2020
@eps1lon
Copy link

eps1lon commented Nov 11, 2020

ISO strings perfectly parses using new Date()

That's debateable. new Date(isoString) just like Date.parse are "discouraged"1 because of browser inconsistencies. Namely Safari assumes UTC when the timezone is missing in the ISO 8601 string while all other browsers assume local time.

date-fns' parseISO resolves these inconsistencies. utils.date should rather use parseISO under the hood if it's used with an ISO date. You can see that in https://cc8j3.csb.app the output of parseISO is consistent across chrome and safari while new Date output is different.

1 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

@dmtrKovalenko
Copy link
Owner

Yeah, that's weird. Thanks @eps1lon I will update the logic accrosss all the adapters

@bartvde
Copy link

bartvde commented Jul 9, 2021

has this been done? I don't see any reference to parseISO in the codebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants