You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The problem I face in my current project is developing a dynamic string such as 10 months, 24 days, 1 minute, and 25 seconds. that is grammatically correct and ignores values that are 0 (or adds if preferred to be more verbose about 0 values). The sentence should also be grammatically correct, swapping between singular and plural as needed.
Describe the solution you'd like
I have a two-fold solution.
Duration and diff practically return the same data. So I propose consolidating the functionality of .diff() into Duration. Instead of doing end.diff(start) you could do Duration(start, end).toDuration() which would perform the difference calculation and return the example I provided above. Coupled with current functionality, Duration.fromObject({}).toDuration() would return the same thing.
Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
Duration and diff practically return the same data. So I propose consolidating the functionality of .diff() into Duration.
This is already true; diff() is a method on DateTime that returns a Duration object. So I'm not really sure what's being proposed here?
Instead of doing end.diff(start) you could do Duration(start, end).toDuration() which would perform the difference calculation and return the example I provided above
You can already do this with Interval: Interval.fromDateTimes(start, end).toDuration() though it is semantically equivalent to end.diff(start)
Is your feature request related to a problem? Please describe.
The problem I face in my current project is developing a dynamic string such as
10 months, 24 days, 1 minute, and 25 seconds.
that is grammatically correct and ignores values that are 0 (or adds if preferred to be more verbose about 0 values). The sentence should also be grammatically correct, swapping between singular and plural as needed.Describe the solution you'd like
I have a two-fold solution.
Duration and diff practically return the same data. So I propose consolidating the functionality of .diff() into Duration. Instead of doing
end.diff(start)
you could doDuration(start, end).toDuration()
which would perform the difference calculation and return the example I provided above. Coupled with current functionality,Duration.fromObject({}).toDuration()
would return the same thing.Describe alternatives you've considered
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: