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

add a Duration::toDateInterval and Duration::fromDateInterval methods #4

Open
nyamsprod opened this issue May 5, 2017 · 2 comments

Comments

@nyamsprod
Copy link

For interoperability you should also add the following methods to the Duration class:

  • Duration::toDateInterval
  • Duration::fromDateInterval
@ocram
Copy link
Contributor

ocram commented May 7, 2017

Definitely, thank you!

For toDateInterval, one solution would be to call Duration#toIso8601 and pass the resulting string to the constructor of the DateInterval class.

For fromDateInterval, do you think it should just read the properties from a DateInterval instance and pass them to Duration::fromDateTime? We should probably pay special attention to the days property on the DateInterval instances that is set only when the instances are the result of a diff.

@nyamsprod
Copy link
Author

yes indeed the days property is the one to pay attention to. :)

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