-
Notifications
You must be signed in to change notification settings - Fork 159
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
Why is options.largestUnit==='days' in Time.prototype.difference? #580
Comments
Here's the thread with context for this particular decision, starting from this point: #307 (comment)
As for throwing or not throwing, I think the rule of thumb we used was to throw if the value would be harmful or nonsensical (e.g. |
Makes sense, thanks for the context. BTW, I just read lower-down in the docs and they are contradictory:
vs.
I assume these should be rationalized? Seems simplest just to lie to the user and claim in both places that the default is 'hours'. Users won't be able to tell, right? For Absolute, I think the ideal answer would be implementing #584 and then setting the default to nanoseconds! ;-) What's powerful about the #584 solution is that you don't have to mix the domains of "how many total minutes are in this Duration?" vs. "what would a stopwatch show for numbers of minutes & seconds for this duration?" |
I'll fix this up.
Right, I don't believe they could unless by inspection of the function's source with |
Clear up this language a bit and explain that the default is effectively hours. Closes: #580
Clear up this language a bit and explain that the default is effectively hours. Closes: #580
I found the docs for for
Time.prototype.difference
to be confusing because:'years'
,'months'
, and'days'
are all accepted even though these fields aren't part of aTime
'days'
which is also not part of aTime
.What I expected:
hours
years
,months
, anddays
should throw OR the docs should clarify that Y/M/D are treated ashours
.I assume that
hours
will behave identically todays
(per #324), so this might just be a documentation issue with no spec or implementation change needed.Here's the current docs:
The text was updated successfully, but these errors were encountered: