@@ -623,41 +623,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
623
623
*/
624
624
open func getEra( _ eraValuePointer: UnsafeMutablePointer < Int > ? , year yearValuePointer: UnsafeMutablePointer < Int > ? , month monthValuePointer: UnsafeMutablePointer < Int > ? , day dayValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
625
625
let comps = components ( [ . era, . year, . month, . day] , from: date)
626
- if let value = comps. era {
627
- eraValuePointer? . pointee = value
628
- } else {
629
- eraValuePointer? . pointee = NSDateComponentUndefined
630
- }
631
- if let value = comps. year {
632
- yearValuePointer? . pointee = value
633
- } else {
634
- yearValuePointer? . pointee = NSDateComponentUndefined
635
- }
636
- if let value = comps. month {
637
- monthValuePointer? . pointee = value
638
- } else {
639
- monthValuePointer? . pointee = NSDateComponentUndefined
640
- }
641
- if let value = comps. day {
642
- dayValuePointer? . pointee = value
643
- } else {
644
- dayValuePointer? . pointee = NSDateComponentUndefined
645
- }
646
- if let value = comps. year {
647
- yearValuePointer? . pointee = value
648
- } else {
649
- yearValuePointer? . pointee = NSDateComponentUndefined
650
- }
651
- if let value = comps. month {
652
- monthValuePointer? . pointee = value
653
- } else {
654
- monthValuePointer? . pointee = NSDateComponentUndefined
655
- }
656
- if let value = comps. day {
657
- dayValuePointer? . pointee = value
658
- } else {
659
- dayValuePointer? . pointee = NSDateComponentUndefined
660
- }
626
+
627
+ eraValuePointer? . pointee = comps. era ?? NSDateComponentUndefined
628
+ yearValuePointer? . pointee = comps. year ?? NSDateComponentUndefined
629
+ monthValuePointer? . pointee = comps. month ?? NSDateComponentUndefined
630
+ dayValuePointer? . pointee = comps. day ?? NSDateComponentUndefined
661
631
}
662
632
663
633
/*
@@ -666,41 +636,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
666
636
*/
667
637
open func getEra( _ eraValuePointer: UnsafeMutablePointer < Int > ? , yearForWeekOfYear yearValuePointer: UnsafeMutablePointer < Int > ? , weekOfYear weekValuePointer: UnsafeMutablePointer < Int > ? , weekday weekdayValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
668
638
let comps = components ( [ . era, . yearForWeekOfYear, . weekOfYear, . weekday] , from: date)
669
- if let value = comps. era {
670
- eraValuePointer? . pointee = value
671
- } else {
672
- eraValuePointer? . pointee = NSDateComponentUndefined
673
- }
674
- if let value = comps. yearForWeekOfYear {
675
- yearValuePointer? . pointee = value
676
- } else {
677
- yearValuePointer? . pointee = NSDateComponentUndefined
678
- }
679
- if let value = comps. weekOfYear {
680
- weekValuePointer? . pointee = value
681
- } else {
682
- weekValuePointer? . pointee = NSDateComponentUndefined
683
- }
684
- if let value = comps. weekday {
685
- weekdayValuePointer? . pointee = value
686
- } else {
687
- weekdayValuePointer? . pointee = NSDateComponentUndefined
688
- }
689
- if let value = comps. yearForWeekOfYear {
690
- yearValuePointer? . pointee = value
691
- } else {
692
- yearValuePointer? . pointee = NSDateComponentUndefined
693
- }
694
- if let value = comps. weekOfYear {
695
- weekValuePointer? . pointee = value
696
- } else {
697
- weekValuePointer? . pointee = NSDateComponentUndefined
698
- }
699
- if let value = comps. weekday {
700
- weekdayValuePointer? . pointee = value
701
- } else {
702
- weekdayValuePointer? . pointee = NSDateComponentUndefined
703
- }
639
+
640
+ eraValuePointer? . pointee = comps. era ?? NSDateComponentUndefined
641
+ yearValuePointer? . pointee = comps. year ?? NSDateComponentUndefined
642
+ weekValuePointer? . pointee = comps. weekOfYear ?? NSDateComponentUndefined
643
+ weekdayValuePointer? . pointee = comps. weekday ?? NSDateComponentUndefined
704
644
}
705
645
706
646
/*
@@ -709,41 +649,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
709
649
*/
710
650
open func getHour( _ hourValuePointer: UnsafeMutablePointer < Int > ? , minute minuteValuePointer: UnsafeMutablePointer < Int > ? , second secondValuePointer: UnsafeMutablePointer < Int > ? , nanosecond nanosecondValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
711
651
let comps = components ( [ . hour, . minute, . second, . nanosecond] , from: date)
712
- if let value = comps. hour {
713
- hourValuePointer? . pointee = value
714
- } else {
715
- hourValuePointer? . pointee = NSDateComponentUndefined
716
- }
717
- if let value = comps. minute {
718
- minuteValuePointer? . pointee = value
719
- } else {
720
- minuteValuePointer? . pointee = NSDateComponentUndefined
721
- }
722
- if let value = comps. second {
723
- secondValuePointer? . pointee = value
724
- } else {
725
- secondValuePointer? . pointee = NSDateComponentUndefined
726
- }
727
- if let value = comps. nanosecond {
728
- nanosecondValuePointer? . pointee = value
729
- } else {
730
- nanosecondValuePointer? . pointee = NSDateComponentUndefined
731
- }
732
- if let value = comps. minute {
733
- minuteValuePointer? . pointee = value
734
- } else {
735
- minuteValuePointer? . pointee = NSDateComponentUndefined
736
- }
737
- if let value = comps. second {
738
- secondValuePointer? . pointee = value
739
- } else {
740
- secondValuePointer? . pointee = NSDateComponentUndefined
741
- }
742
- if let value = comps. nanosecond {
743
- nanosecondValuePointer? . pointee = value
744
- } else {
745
- nanosecondValuePointer? . pointee = NSDateComponentUndefined
746
- }
652
+
653
+ hourValuePointer? . pointee = comps. hour ?? NSDateComponentUndefined
654
+ minuteValuePointer? . pointee = comps. minute ?? NSDateComponentUndefined
655
+ secondValuePointer? . pointee = comps. second ?? NSDateComponentUndefined
656
+ nanosecondValuePointer? . pointee = comps. nanosecond ?? NSDateComponentUndefined
747
657
}
748
658
749
659
/*
0 commit comments