-
-
Notifications
You must be signed in to change notification settings - Fork 30
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 LocalDateRange::toPeriod #51
Comments
I am not really fan of this Period concept. Never used it in my production. |
In the case of |
Just tried it on Java, the output of the example above is And the implementation just uses |
Implemented in 213a4ba. |
Following #48, in addition to
LocalDateRange::getDuration
, it would be useful to add aLocalDateRange::toPeriod()
method.There are several ways to implement this method. Take for example
2021-03-28/2022-04-01
, we can represent it as either:Not sure which one we should choose here. The first one has a negative part for a non-negative range, so is probably not that intuitive; the third one is probably not what you would expect either, and one may argue that if you just want a raw number of days, you may use
getDuration()
instead. So at first glance, I'd go with the second option.Another solution could be to offer several methods, but this can add to confusion.
I can see that Java's threeten-extra has a toPeriod method, it would be nice to see which way they followed.
Cc @solodkiy
The text was updated successfully, but these errors were encountered: