Skip to content

Commit 0847883

Browse files
author
Robert F. Dickerson
committed
Migrated NSCalendar to new API
1 parent 30be519 commit 0847883

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Foundation/NSCalendar.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,9 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
624624
Create a date with given components.
625625
Current era is assumed.
626626
*/
627-
public func dateWithEra(_ eraValue: Int, year yearValue: Int, month monthValue: Int, day dayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
627+
public func date(_ era: Int, year yearValue: Int, month monthValue: Int, day dayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
628628
let comps = NSDateComponents()
629-
comps.era = eraValue
629+
comps.era = era
630630
comps.year = yearValue
631631
comps.month = monthValue
632632
comps.day = dayValue
@@ -641,9 +641,9 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
641641
Create a date with given components.
642642
Current era is assumed.
643643
*/
644-
public func dateWithEra(_ eraValue: Int, yearForWeekOfYear yearValue: Int, weekOfYear weekValue: Int, weekday weekdayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
644+
public func date(_ era: Int, yearForWeekOfYear yearValue: Int, weekOfYear weekValue: Int, weekday weekdayValue: Int, hour hourValue: Int, minute minuteValue: Int, second secondValue: Int, nanosecond nanosecondValue: Int) -> NSDate? {
645645
let comps = NSDateComponents()
646-
comps.era = eraValue
646+
comps.era = era
647647
comps.yearForWeekOfYear = yearValue
648648
comps.weekOfYear = weekValue
649649
comps.weekday = weekdayValue
@@ -965,7 +965,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
965965
Result dates have an integer number of seconds (as if 0 was specified for the nanoseconds property of the NSDateComponents matching parameter), unless a value was set in the nanoseconds property, in which case the result date will have that number of nanoseconds (or as close as possible with floating point numbers).
966966
The enumeration is stopped by setting *stop = YES in the block and return. It is not necessary to set *stop to NO to keep the enumeration going.
967967
*/
968-
public func enumerateDatesStartingAfterDate(_ start: NSDate, matchingComponents comps: NSDateComponents, options opts: NSCalendarOptions, usingBlock block: (NSDate?, Bool, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
968+
public func enumerateDates(_ startingAfter: NSDate, matching comps: NSDateComponents, options opts: NSCalendarOptions, using block: (NSDate?, Bool, UnsafeMutablePointer<ObjCBool>) -> Void) { NSUnimplemented() }
969969

970970
/*
971971
This method computes the next date which matches (or most closely matches) a given set of components.
@@ -974,7 +974,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
974974
*/
975975
public func nextDateAfterDate(_ date: NSDate, matchingComponents comps: NSDateComponents, options: NSCalendarOptions) -> NSDate? {
976976
var result: NSDate?
977-
enumerateDatesStartingAfterDate(date, matchingComponents: comps, options: options) { date, exactMatch, stop in
977+
enumerateDates(date, matching: comps, options: options) { date, exactMatch, stop in
978978
result = date
979979
stop.pointee = true
980980
}
@@ -1019,7 +1019,7 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
10191019
let targetComp = NSDateComponents()
10201020
targetComp.setValue(v, forComponent: unit)
10211021
var result: NSDate?
1022-
enumerateDatesStartingAfterDate(date, matchingComponents: targetComp, options: .MatchNextTime) { date, match, stop in
1022+
enumerateDates(date, matching: targetComp, options: .MatchNextTime) { date, match, stop in
10231023
result = date
10241024
stop.pointee = true
10251025
}

0 commit comments

Comments
 (0)