|
|
@ -69,7 +69,6 @@ public extension Date { |
|
|
|
stepLarger = Calendar.Component.era |
|
|
|
stepLarger = Calendar.Component.era |
|
|
|
stepSmaller = Calendar.Component.year |
|
|
|
stepSmaller = Calendar.Component.year |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
break |
|
|
|
|
|
|
|
case 1: |
|
|
|
case 1: |
|
|
|
if smaller.hashValue > 2 { |
|
|
|
if smaller.hashValue > 2 { |
|
|
|
break |
|
|
|
break |
|
|
@ -78,7 +77,6 @@ public extension Date { |
|
|
|
stepSmaller = Calendar.Component.month |
|
|
|
stepSmaller = Calendar.Component.month |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
if larger.hashValue < 2 { |
|
|
|
if larger.hashValue < 2 { |
|
|
|
if self.isInLeapYear { |
|
|
|
if self.isInLeapYear { |
|
|
@ -91,22 +89,18 @@ public extension Date { |
|
|
|
stepSmaller = Calendar.Component.day |
|
|
|
stepSmaller = Calendar.Component.day |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
|
|
|
|
case 3: |
|
|
|
case 3: |
|
|
|
stepLarger = Calendar.Component.day |
|
|
|
stepLarger = Calendar.Component.day |
|
|
|
stepSmaller = Calendar.Component.hour |
|
|
|
stepSmaller = Calendar.Component.hour |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
break |
|
|
|
|
|
|
|
case 4: |
|
|
|
case 4: |
|
|
|
stepLarger = Calendar.Component.hour |
|
|
|
stepLarger = Calendar.Component.hour |
|
|
|
stepSmaller = Calendar.Component.minute |
|
|
|
stepSmaller = Calendar.Component.minute |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
break |
|
|
|
|
|
|
|
case 5: |
|
|
|
case 5: |
|
|
|
stepLarger = Calendar.Component.minute |
|
|
|
stepLarger = Calendar.Component.minute |
|
|
|
stepSmaller = Calendar.Component.second |
|
|
|
stepSmaller = Calendar.Component.second |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
unitRange = calendar.range(of: stepSmaller, in: stepLarger, for: self) |
|
|
|
break |
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|