@@ -644,41 +644,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
644
644
*/
645
645
open func getEra( _ eraValuePointer: UnsafeMutablePointer < Int > ? , year yearValuePointer: UnsafeMutablePointer < Int > ? , month monthValuePointer: UnsafeMutablePointer < Int > ? , day dayValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
646
646
let comps = components ( [ . era, . year, . month, . day] , from: date)
647
- if let value = comps. era {
648
- eraValuePointer? . pointee = value
649
- } else {
650
- eraValuePointer? . pointee = NSDateComponentUndefined
651
- }
652
- if let value = comps. year {
653
- yearValuePointer? . pointee = value
654
- } else {
655
- yearValuePointer? . pointee = NSDateComponentUndefined
656
- }
657
- if let value = comps. month {
658
- monthValuePointer? . pointee = value
659
- } else {
660
- monthValuePointer? . pointee = NSDateComponentUndefined
661
- }
662
- if let value = comps. day {
663
- dayValuePointer? . pointee = value
664
- } else {
665
- dayValuePointer? . pointee = NSDateComponentUndefined
666
- }
667
- if let value = comps. year {
668
- yearValuePointer? . pointee = value
669
- } else {
670
- yearValuePointer? . pointee = NSDateComponentUndefined
671
- }
672
- if let value = comps. month {
673
- monthValuePointer? . pointee = value
674
- } else {
675
- monthValuePointer? . pointee = NSDateComponentUndefined
676
- }
677
- if let value = comps. day {
678
- dayValuePointer? . pointee = value
679
- } else {
680
- dayValuePointer? . pointee = NSDateComponentUndefined
681
- }
647
+
648
+ eraValuePointer? . pointee = comps. era ?? NSDateComponentUndefined
649
+ yearValuePointer? . pointee = comps. year ?? NSDateComponentUndefined
650
+ monthValuePointer? . pointee = comps. month ?? NSDateComponentUndefined
651
+ dayValuePointer? . pointee = comps. day ?? NSDateComponentUndefined
682
652
}
683
653
684
654
/*
@@ -687,41 +657,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
687
657
*/
688
658
open func getEra( _ eraValuePointer: UnsafeMutablePointer < Int > ? , yearForWeekOfYear yearValuePointer: UnsafeMutablePointer < Int > ? , weekOfYear weekValuePointer: UnsafeMutablePointer < Int > ? , weekday weekdayValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
689
659
let comps = components ( [ . era, . yearForWeekOfYear, . weekOfYear, . weekday] , from: date)
690
- if let value = comps. era {
691
- eraValuePointer? . pointee = value
692
- } else {
693
- eraValuePointer? . pointee = NSDateComponentUndefined
694
- }
695
- if let value = comps. yearForWeekOfYear {
696
- yearValuePointer? . pointee = value
697
- } else {
698
- yearValuePointer? . pointee = NSDateComponentUndefined
699
- }
700
- if let value = comps. weekOfYear {
701
- weekValuePointer? . pointee = value
702
- } else {
703
- weekValuePointer? . pointee = NSDateComponentUndefined
704
- }
705
- if let value = comps. weekday {
706
- weekdayValuePointer? . pointee = value
707
- } else {
708
- weekdayValuePointer? . pointee = NSDateComponentUndefined
709
- }
710
- if let value = comps. yearForWeekOfYear {
711
- yearValuePointer? . pointee = value
712
- } else {
713
- yearValuePointer? . pointee = NSDateComponentUndefined
714
- }
715
- if let value = comps. weekOfYear {
716
- weekValuePointer? . pointee = value
717
- } else {
718
- weekValuePointer? . pointee = NSDateComponentUndefined
719
- }
720
- if let value = comps. weekday {
721
- weekdayValuePointer? . pointee = value
722
- } else {
723
- weekdayValuePointer? . pointee = NSDateComponentUndefined
724
- }
660
+
661
+ eraValuePointer? . pointee = comps. era ?? NSDateComponentUndefined
662
+ yearValuePointer? . pointee = comps. year ?? NSDateComponentUndefined
663
+ weekValuePointer? . pointee = comps. weekOfYear ?? NSDateComponentUndefined
664
+ weekdayValuePointer? . pointee = comps. weekday ?? NSDateComponentUndefined
725
665
}
726
666
727
667
/*
@@ -730,41 +670,11 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
730
670
*/
731
671
open func getHour( _ hourValuePointer: UnsafeMutablePointer < Int > ? , minute minuteValuePointer: UnsafeMutablePointer < Int > ? , second secondValuePointer: UnsafeMutablePointer < Int > ? , nanosecond nanosecondValuePointer: UnsafeMutablePointer < Int > ? , from date: Date ) {
732
672
let comps = components ( [ . hour, . minute, . second, . nanosecond] , from: date)
733
- if let value = comps. hour {
734
- hourValuePointer? . pointee = value
735
- } else {
736
- hourValuePointer? . pointee = NSDateComponentUndefined
737
- }
738
- if let value = comps. minute {
739
- minuteValuePointer? . pointee = value
740
- } else {
741
- minuteValuePointer? . pointee = NSDateComponentUndefined
742
- }
743
- if let value = comps. second {
744
- secondValuePointer? . pointee = value
745
- } else {
746
- secondValuePointer? . pointee = NSDateComponentUndefined
747
- }
748
- if let value = comps. nanosecond {
749
- nanosecondValuePointer? . pointee = value
750
- } else {
751
- nanosecondValuePointer? . pointee = NSDateComponentUndefined
752
- }
753
- if let value = comps. minute {
754
- minuteValuePointer? . pointee = value
755
- } else {
756
- minuteValuePointer? . pointee = NSDateComponentUndefined
757
- }
758
- if let value = comps. second {
759
- secondValuePointer? . pointee = value
760
- } else {
761
- secondValuePointer? . pointee = NSDateComponentUndefined
762
- }
763
- if let value = comps. nanosecond {
764
- nanosecondValuePointer? . pointee = value
765
- } else {
766
- nanosecondValuePointer? . pointee = NSDateComponentUndefined
767
- }
673
+
674
+ hourValuePointer? . pointee = comps. hour ?? NSDateComponentUndefined
675
+ minuteValuePointer? . pointee = comps. minute ?? NSDateComponentUndefined
676
+ secondValuePointer? . pointee = comps. second ?? NSDateComponentUndefined
677
+ nanosecondValuePointer? . pointee = comps. nanosecond ?? NSDateComponentUndefined
768
678
}
769
679
770
680
/*
0 commit comments