@@ -177,15 +177,10 @@ impl ResolvedRoundingOptions {
177177 pub ( crate ) fn from_diff_settings (
178178 options : DifferenceSettings ,
179179 operation : DifferenceOperation ,
180- unit_group : UnitGroup ,
181180 fallback_largest : TemporalUnit ,
182181 fallback_smallest : TemporalUnit ,
183182 ) -> TemporalResult < Self > {
184183 // 4. Let resolvedOptions be ? SnapshotOwnProperties(? GetOptionsObject(options), null).
185- let largest_unit = options
186- . largest_unit
187- . map ( |unit| unit. assert_unit_group ( unit_group) )
188- . transpose ( ) ?;
189184 // 5. Let settings be ? GetDifferenceSettings(operation, resolvedOptions, DATE, « », "day", "day").
190185 let increment = options. increment . unwrap_or_default ( ) ;
191186 let rounding_mode = match operation {
@@ -199,7 +194,9 @@ impl ResolvedRoundingOptions {
199194 } ;
200195 let smallest_unit = options. smallest_unit . unwrap_or ( fallback_smallest) ;
201196 // Use the defaultlargestunit which is max smallestlargestdefault and smallestunit
202- let largest_unit = largest_unit. unwrap_or ( smallest_unit. max ( fallback_largest) ) ;
197+ let largest_unit = options
198+ . largest_unit
199+ . unwrap_or ( smallest_unit. max ( fallback_largest) ) ;
203200
204201 // 11. If LargerOfTwoTemporalUnits(largestUnit, smallestUnit) is not largestUnit, throw a RangeError exception.
205202 // 12. Let maximum be MaximumTemporalDurationRoundingIncrement(smallestUnit).
@@ -344,12 +341,6 @@ impl ResolvedRoundingOptions {
344341
345342// ==== Options enums and methods ====
346343
347- pub enum UnitGroup {
348- Date ,
349- Time ,
350- DateTime ,
351- }
352-
353344/// The relevant unit that should be used for the operation that
354345/// this option is provided as a value.
355346#[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord ) ]
@@ -442,19 +433,6 @@ impl TemporalUnit {
442433 Hour | Minute | Second | Millisecond | Microsecond | Nanosecond
443434 )
444435 }
445-
446- #[ inline]
447- pub fn assert_unit_group ( self , group : UnitGroup ) -> TemporalResult < Self > {
448- match group {
449- UnitGroup :: Date if !self . is_calendar_unit ( ) || self != TemporalUnit :: Day => {
450- Err ( TemporalError :: range ( ) . with_message ( "Unit must be a date unit." ) )
451- }
452- UnitGroup :: Time if !self . is_time_unit ( ) => {
453- Err ( TemporalError :: range ( ) . with_message ( "Unit must be a time unit." ) )
454- }
455- _ => Ok ( self ) ,
456- }
457- }
458436}
459437
460438impl From < usize > for TemporalUnit {
0 commit comments