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

Use NSISO8601DateFormatter when available #74

Open
boredzo opened this issue Jul 2, 2016 · 1 comment
Open

Use NSISO8601DateFormatter when available #74

boredzo opened this issue Jul 2, 2016 · 1 comment

Comments

@boredzo
Copy link
Owner

boredzo commented Jul 2, 2016

On macOS 10.12 and iOS 10, Foundation has an NSISO8601DateFormatter class built in. It'd be cool if ISO8601DateFormatter wrapped that implementation when it's available, as an aid to clients who'd like to move toward that implementation.

Ingredients:

  • Don't delete the existing implementation—clients supporting older OS versions will still need it.
  • Ensure calls to ISO8601DateFormatter methods reach NSISO8601DateFormatter implementations when available. There are many ways you could achieve this: Return an NSISO8601DateFormatter from alloc; have a class cluster; return the result of the NSISO8601DateFormatter implementation at the start of each ISO8601DateFormatter implementation—up to you.
  • NSISO8601DateFormatter property and method names may differ from those in ISO8601DateFormatter. Add methods with NSISO8601DateFormatter's names to ISO8601DateFormatter that call either the method of the same name on an actual NSISO8601DateFormatter (if possible) or the equivalent method in the ISO8601DateFormatter.
@kengruven
Copy link

kengruven commented May 29, 2020

As a parser, NSISO8601DateFormatter is actually pretty different from boredzo/ISO8601DateFormatter. The NS one is basically just some ISO-8601-specific presets for their date parser. That is, I can take any valid ISO-8601 string and pass it to boredzo/ISO8601DateFormatter and get a Date object out of it. In order to pass an ISO-8601 string to NSISO8601DateFormatter, I have to first tell the parser exactly which variant of ISO-8601 to expect.

That's not workable for my program, so I'll be sticking with boredzo/ISO8601DateFormatter.

It may be feasible to replace the formatting half of ISO8601DateFormatter with the NS implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants