-
Notifications
You must be signed in to change notification settings - Fork 149
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
Rounding, Part 2 #907
Rounding, Part 2 #907
Conversation
Codecov Report
@@ Coverage Diff @@
## main #907 +/- ##
==========================================
+ Coverage 93.18% 93.54% +0.35%
==========================================
Files 17 17
Lines 5373 5671 +298
Branches 826 856 +30
==========================================
+ Hits 5007 5305 +298
Misses 359 359
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
929ab41
to
8814097
Compare
const largestUnit = ES.ToLargestTemporalUnit(options, 'seconds', ['years', 'months', 'weeks', 'days']); | ||
const disallowedUnits = ['years', 'months', 'weeks', 'days']; | ||
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds', disallowedUnits); | ||
let defaultLargestUnit = 'seconds'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let defaultLargestUnit = 'seconds'; | |
const defaultLargestUnit = 'seconds'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's reassigned in the next line if smallestUnit
is larger than defaultLargestUnit
.
8814097
to
abf2474
Compare
Includes several new abstract operations: - ToSmallestTemporalDurationUnit, which is distinct from ToSmallestTemporalUnit because it prefers plural unit names and does have a fallback value; - ValidateTemporalDifferenceUnits, which makes sure that largestUnit is not smaller than smallestUnit; - and MaximumTemporalDurationRoundingIncrement, which computes the maximum (not inclusive) value for roundingIncrement given the value of smallestUnit, for rounding a Temporal.Duration. All of these will be reused for Temporal.DateTime.difference and Temporal.Time.difference in subsequent commits. See: #827
Includes a new abstract operation RoundDuration, which will be used in the other types' difference() methods and Temporal.Duration.round as well. See: #827
abf2474
to
181793d
Compare
This adds rounding options to Temporal.Absolute.prototype.difference, Temporal.DateTime.prototype.difference, and Temporal.Time.prototype.difference.
See: #827.