Skip to content

Commit 7f85f73

Browse files
committed
Drop NS from TimeInterval
1 parent 9852cdd commit 7f85f73

15 files changed

+66
-63
lines changed

Foundation.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,7 @@
17121712
TargetAttributes = {
17131713
5B5D885C1BBC938800234F36 = {
17141714
CreatedOnToolsVersion = 7.1;
1715+
LastSwiftUpdateCheck = 0800;
17151716
ProvisioningStyle = Manual;
17161717
};
17171718
5B7C8A6D1BEA7F8F00C5B690 = {
@@ -1720,10 +1721,12 @@
17201721
};
17211722
5BDC405B1BD6D83B00ED97BB = {
17221723
CreatedOnToolsVersion = 7.1;
1724+
LastSwiftUpdateCheck = 0800;
17231725
ProvisioningStyle = Manual;
17241726
};
17251727
EA66F66E1BF56CCB00136161 = {
17261728
CreatedOnToolsVersion = 7.1;
1729+
LastSwiftUpdateCheck = 0800;
17271730
ProvisioningStyle = Manual;
17281731
};
17291732
};

Foundation/Date.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import CoreFoundation
1414
public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringConvertible {
1515
public typealias ReferenceType = NSDate
1616

17-
private var _time : NSTimeInterval
17+
private var _time : TimeInterval
1818

1919
/// The number of seconds from 1 January 1970 to the reference date, 1 January 2001.
2020
public static let timeIntervalBetween1970AndReferenceDate = 978307200.0
2121

2222
/// The interval between 00:00:00 UTC on 1 January 2001 and the current date and time.
23-
public static var timeIntervalSinceReferenceDate : NSTimeInterval {
23+
public static var timeIntervalSinceReferenceDate : TimeInterval {
2424
return CFAbsoluteTimeGetCurrent()
2525
}
2626

@@ -30,12 +30,12 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
3030
}
3131

3232
/// Returns a `Date` initialized relative to the current date and time by a given number of seconds.
33-
public init(timeIntervalSinceNow: NSTimeInterval) {
33+
public init(timeIntervalSinceNow: TimeInterval) {
3434
self.init(timeIntervalSinceReferenceDate: timeIntervalSinceNow + CFAbsoluteTimeGetCurrent())
3535
}
3636

3737
/// Returns a `Date` initialized relative to 00:00:00 UTC on 1 January 1970 by a given number of seconds.
38-
public init(timeIntervalSince1970: NSTimeInterval) {
38+
public init(timeIntervalSince1970: TimeInterval) {
3939
self.init(timeIntervalSinceReferenceDate: timeIntervalSince1970 - Date.timeIntervalBetween1970AndReferenceDate)
4040
}
4141

@@ -45,12 +45,12 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
4545
- Parameter timeInterval: The number of seconds to add to `date`. A negative value means the receiver will be earlier than `date`.
4646
- Parameter date: The reference date.
4747
*/
48-
public init(timeInterval: NSTimeInterval, since date: Date) {
48+
public init(timeInterval: TimeInterval, since date: Date) {
4949
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate + timeInterval)
5050
}
5151

5252
/// Returns an `Date` initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.
53-
public init(timeIntervalSinceReferenceDate ti: NSTimeInterval) {
53+
public init(timeIntervalSinceReferenceDate ti: TimeInterval) {
5454
_time = ti
5555
}
5656

@@ -68,7 +68,7 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
6868

6969
This property’s value is negative if the date object is earlier than the system’s absolute reference date (00:00:00 UTC on 1 January 2001).
7070
*/
71-
public var timeIntervalSinceReferenceDate: NSTimeInterval {
71+
public var timeIntervalSinceReferenceDate: TimeInterval {
7272
return _time
7373
}
7474

@@ -83,7 +83,7 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
8383
- SeeAlso: `timeIntervalSinceNow`
8484
- SeeAlso: `timeIntervalSinceReferenceDate`
8585
*/
86-
public func timeIntervalSince(_ date: Date) -> NSTimeInterval {
86+
public func timeIntervalSince(_ date: Date) -> TimeInterval {
8787
return self.timeIntervalSinceReferenceDate - date.timeIntervalSinceReferenceDate
8888
}
8989

@@ -96,7 +96,7 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
9696
- SeeAlso: `timeIntervalSince1970`
9797
- SeeAlso: `timeIntervalSinceReferenceDate`
9898
*/
99-
public var timeIntervalSinceNow: NSTimeInterval {
99+
public var timeIntervalSinceNow: TimeInterval {
100100
return self.timeIntervalSinceReferenceDate - CFAbsoluteTimeGetCurrent()
101101
}
102102

@@ -109,7 +109,7 @@ public struct Date : ReferenceConvertible, Comparable, Equatable, CustomStringCo
109109
- SeeAlso: `timeIntervalSinceNow`
110110
- SeeAlso: `timeIntervalSinceReferenceDate`
111111
*/
112-
public var timeIntervalSince1970: NSTimeInterval {
112+
public var timeIntervalSince1970: TimeInterval {
113113
return self.timeIntervalSinceReferenceDate + Date.timeIntervalBetween1970AndReferenceDate
114114
}
115115

@@ -180,19 +180,19 @@ public func <(lhs: Date, rhs: Date) -> Bool {
180180
}
181181

182182
/// Returns a Date with a specified amount of time added to it.
183-
public func +(lhs: Date, rhs: NSTimeInterval) -> Date {
183+
public func +(lhs: Date, rhs: TimeInterval) -> Date {
184184
return Date(timeIntervalSinceReferenceDate: lhs.timeIntervalSinceReferenceDate + rhs)
185185
}
186186

187187
/// Returns a Date with a specified amount of time subtracted from it.
188-
public func -(lhs: Date, rhs: NSTimeInterval) -> Date {
188+
public func -(lhs: Date, rhs: TimeInterval) -> Date {
189189
return Date(timeIntervalSinceReferenceDate: lhs.timeIntervalSinceReferenceDate - rhs)
190190
}
191191

192-
public func +=(lhs: inout Date, rhs: NSTimeInterval) {
192+
public func +=(lhs: inout Date, rhs: TimeInterval) {
193193
lhs = lhs + rhs
194194
}
195195

196-
public func -=(lhs: inout Date, rhs: NSTimeInterval) {
196+
public func -=(lhs: inout Date, rhs: TimeInterval) {
197197
lhs = lhs - rhs
198198
}

Foundation/NSDate.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import CoreFoundation
1515
import Glibc
1616
#endif
1717

18-
public typealias NSTimeInterval = Double
18+
public typealias TimeInterval = Double
1919

2020
public var NSTimeIntervalSince1970: Double {
2121
return 978307200.0
@@ -45,9 +45,9 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
4545
}
4646

4747
internal let _base = _CFInfo(typeID: CFDateGetTypeID())
48-
internal let _timeIntervalSinceReferenceDate: NSTimeInterval
48+
internal let _timeIntervalSinceReferenceDate: TimeInterval
4949

50-
public var timeIntervalSinceReferenceDate: NSTimeInterval {
50+
public var timeIntervalSinceReferenceDate: TimeInterval {
5151
return _timeIntervalSinceReferenceDate
5252
}
5353

@@ -56,12 +56,12 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
5656
let _ = withUnsafeMutablePointer(&tv) { t in
5757
gettimeofday(t, nil)
5858
}
59-
var timestamp = NSTimeInterval(tv.tv_sec) - NSTimeIntervalSince1970
60-
timestamp += NSTimeInterval(tv.tv_usec) / 1000000.0
59+
var timestamp = TimeInterval(tv.tv_sec) - NSTimeIntervalSince1970
60+
timestamp += TimeInterval(tv.tv_usec) / 1000000.0
6161
self.init(timeIntervalSinceReferenceDate: timestamp)
6262
}
6363

64-
public required init(timeIntervalSinceReferenceDate ti: NSTimeInterval) {
64+
public required init(timeIntervalSinceReferenceDate ti: TimeInterval) {
6565
_timeIntervalSinceReferenceDate = ti
6666
}
6767

@@ -70,7 +70,7 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
7070
let ti = aDecoder.decodeDoubleForKey("NS.time")
7171
self.init(timeIntervalSinceReferenceDate: ti)
7272
} else {
73-
var ti: NSTimeInterval = 0.0
73+
var ti: TimeInterval = 0.0
7474
withUnsafeMutablePointer(&ti) { (ptr: UnsafeMutablePointer<Double>) -> Void in
7575
aDecoder.decodeValueOfObjCType("d", at: UnsafeMutablePointer<Void>(ptr))
7676
}
@@ -149,19 +149,19 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
149149

150150
extension NSDate {
151151

152-
public func timeIntervalSince(_ anotherDate: Date) -> NSTimeInterval {
152+
public func timeIntervalSince(_ anotherDate: Date) -> TimeInterval {
153153
return self.timeIntervalSinceReferenceDate - anotherDate.timeIntervalSinceReferenceDate
154154
}
155155

156-
public var timeIntervalSinceNow: NSTimeInterval {
156+
public var timeIntervalSinceNow: TimeInterval {
157157
return timeIntervalSince(Date())
158158
}
159159

160-
public var timeIntervalSince1970: NSTimeInterval {
160+
public var timeIntervalSince1970: TimeInterval {
161161
return timeIntervalSinceReferenceDate + NSTimeIntervalSince1970
162162
}
163163

164-
public func addingTimeInterval(_ ti: NSTimeInterval) -> Date {
164+
public func addingTimeInterval(_ ti: TimeInterval) -> Date {
165165
return Date(timeIntervalSinceReferenceDate:_timeIntervalSinceReferenceDate + ti)
166166
}
167167

@@ -209,15 +209,15 @@ extension NSDate {
209209
return _distantPast
210210
}
211211

212-
public convenience init(timeIntervalSinceNow secs: NSTimeInterval) {
212+
public convenience init(timeIntervalSinceNow secs: TimeInterval) {
213213
self.init(timeIntervalSinceReferenceDate: secs + Date().timeIntervalSinceReferenceDate)
214214
}
215215

216-
public convenience init(timeIntervalSince1970 secs: NSTimeInterval) {
216+
public convenience init(timeIntervalSince1970 secs: TimeInterval) {
217217
self.init(timeIntervalSinceReferenceDate: secs - NSTimeIntervalSince1970)
218218
}
219219

220-
public convenience init(timeInterval secsToBeAdded: NSTimeInterval, sinceDate date: Date) {
220+
public convenience init(timeInterval secsToBeAdded: TimeInterval, sinceDate date: Date) {
221221
self.init(timeIntervalSinceReferenceDate: date.timeIntervalSinceReferenceDate + secsToBeAdded)
222222
}
223223
}
@@ -252,7 +252,7 @@ public class NSDateInterval : NSObject {
252252
public internal(set) var start: Date
253253
public internal(set) var end: Date
254254

255-
public var interval: NSTimeInterval {
255+
public var interval: TimeInterval {
256256
return end.timeIntervalSinceReferenceDate - start.timeIntervalSinceReferenceDate
257257
}
258258

@@ -261,7 +261,7 @@ public class NSDateInterval : NSObject {
261261
self.end = end
262262
}
263263

264-
public convenience init(start: Date, interval: NSTimeInterval) {
264+
public convenience init(start: Date, interval: TimeInterval) {
265265
self.init(start: start, end: Date(timeInterval: interval, since: start))
266266
}
267267
}

Foundation/NSDateComponentsFormatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class DateComponentsFormatter : Formatter {
6363

6464
/* Convenience method for formatting a number of seconds. See 'allowedUnits' for how the default set of allowed units differs from -stringFromDateComponents:.
6565
*/
66-
public func stringFromTimeInterval(_ ti: NSTimeInterval) -> String? { NSUnimplemented() }
66+
public func stringFromTimeInterval(_ ti: TimeInterval) -> String? { NSUnimplemented() }
6767

6868
public class func localizedStringFromDateComponents(_ components: NSDateComponents, unitsStyle: UnitsStyle) -> String? { NSUnimplemented() }
6969

Foundation/NSProcessInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public class NSProcessInfo : NSObject {
145145
return true
146146
}
147147

148-
public var systemUptime: NSTimeInterval {
148+
public var systemUptime: TimeInterval {
149149
return CFGetSystemUptime()
150150
}
151151
}

Foundation/NSThread.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public class NSThread : NSObject {
100100
}
101101
}
102102

103-
public class func sleepForTimeInterval(_ interval: NSTimeInterval) {
103+
public class func sleepForTimeInterval(_ interval: TimeInterval) {
104104
var ti = interval
105105
let start_ut = CFGetSystemUptime()
106106
let end_ut = start_ut + ti

Foundation/NSTimeZone.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class NSTimeZone : NSObject, NSCopying, NSSecureCoding, NSCoding {
153153
}
154154
}
155155

156-
public func daylightSavingTimeOffset(for aDate: Date) -> NSTimeInterval {
156+
public func daylightSavingTimeOffset(for aDate: Date) -> TimeInterval {
157157
if self.dynamicType === NSTimeZone.self {
158158
return CFTimeZoneGetDaylightSavingTimeOffset(_cfObject, aDate.timeIntervalSinceReferenceDate)
159159
} else {
@@ -219,7 +219,7 @@ extension NSTimeZone {
219219
}
220220

221221
public var daylightSavingTime: Bool { NSUnimplemented() }
222-
public var daylightSavingTimeOffset: NSTimeInterval { NSUnimplemented() }
222+
public var daylightSavingTimeOffset: TimeInterval { NSUnimplemented() }
223223
/*@NSCopying*/ public var nextDaylightSavingTimeTransition: Date? { NSUnimplemented() }
224224

225225
public func isEqual(to aTimeZone: NSTimeZone) -> Bool {

Foundation/NSTimer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class NSTimer : NSObject {
3434
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative to creation via selector
3535
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
3636
/// - Warning: Capturing the timer or the owner of the timer inside of the block may cause retain cycles. Use with caution
37-
public init(fireDate: Date, interval: NSTimeInterval, repeats: Bool, fire: (NSTimer) -> Void ) {
37+
public init(fireDate: Date, interval: TimeInterval, repeats: Bool, fire: (NSTimer) -> Void ) {
3838
super.init()
3939
_fire = fire
4040
var context = CFRunLoopTimerContext()
@@ -55,7 +55,7 @@ public class NSTimer : NSObject {
5555
/// - Experiment: This is a draft API currently under consideration for official import into Foundation as a suitable alternative to creation via selector
5656
/// - Note: Since this API is under consideration it may be either removed or revised in the near future
5757
/// - Warning: Capturing the timer or the owner of the timer inside of the block may cause retain cycles. Use with caution
58-
public class func scheduledTimer(_ ti: NSTimeInterval, repeats: Bool, fire: (NSTimer) -> Void) -> NSTimer {
58+
public class func scheduledTimer(_ ti: TimeInterval, repeats: Bool, fire: (NSTimer) -> Void) -> NSTimer {
5959
let timer = NSTimer(fireDate: Date(timeIntervalSinceNow: ti), interval: ti, repeats: repeats, fire: fire)
6060
CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer._timer!, kCFRunLoopDefaultMode)
6161
return timer
@@ -80,11 +80,11 @@ public class NSTimer : NSObject {
8080
}
8181
}
8282

83-
public var timeInterval: NSTimeInterval {
83+
public var timeInterval: TimeInterval {
8484
return CFRunLoopTimerGetInterval(_timer!)
8585
}
8686

87-
public var tolerance: NSTimeInterval {
87+
public var tolerance: TimeInterval {
8888
get {
8989
return CFRunLoopTimerGetTolerance(_timer!)
9090
}

Foundation/NSURLRequest.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public class NSURLRequest: NSObject, NSSecureCoding, NSCopying, NSMutableCopying
135135
self.init(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 60.0)
136136
}
137137

138-
public init(url: URL, cachePolicy: NSURLRequest.CachePolicy, timeoutInterval: NSTimeInterval) {
138+
public init(url: URL, cachePolicy: NSURLRequest.CachePolicy, timeoutInterval: TimeInterval) {
139139
self.url = url
140140
_cachePolicy = cachePolicy
141141
_timeoutInterval = timeoutInterval
@@ -183,8 +183,8 @@ public class NSURLRequest: NSObject, NSSecureCoding, NSCopying, NSMutableCopying
183183
return _cachePolicy
184184
}
185185

186-
internal var _timeoutInterval: NSTimeInterval = 60.0
187-
public var timeoutInterval: NSTimeInterval {
186+
internal var _timeoutInterval: TimeInterval = 60.0
187+
public var timeoutInterval: TimeInterval {
188188
return _timeoutInterval
189189
}
190190

@@ -299,7 +299,7 @@ public class NSMutableURLRequest : NSURLRequest {
299299
self.init(url: url, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 60.0)
300300
}
301301

302-
public override init(url: URL, cachePolicy: NSURLRequest.CachePolicy, timeoutInterval: NSTimeInterval) {
302+
public override init(url: URL, cachePolicy: NSURLRequest.CachePolicy, timeoutInterval: TimeInterval) {
303303
super.init(url: url, cachePolicy: cachePolicy, timeoutInterval: timeoutInterval)
304304
}
305305

@@ -339,7 +339,7 @@ public class NSMutableURLRequest : NSURLRequest {
339339
}
340340
}
341341

342-
public override var timeoutInterval: NSTimeInterval {
342+
public override var timeoutInterval: TimeInterval {
343343
get {
344344
return _timeoutInterval
345345
}

Foundation/NSURLSession.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,14 @@ public class URLSessionStreamTask: URLSessionTask {
379379
* If an error occurs, any outstanding reads will also fail, and new
380380
* read requests will error out immediately.
381381
*/
382-
public func readDataOfMinLength(_ minBytes: Int, maxLength maxBytes: Int, timeout: NSTimeInterval, completionHandler: (NSData?, Bool, NSError?) -> Void) { NSUnimplemented() }
382+
public func readDataOfMinLength(_ minBytes: Int, maxLength maxBytes: Int, timeout: TimeInterval, completionHandler: (NSData?, Bool, NSError?) -> Void) { NSUnimplemented() }
383383

384384
/* Write the data completely to the underlying socket. If all the
385385
* bytes have not been written by the timeout, a timeout error will
386386
* occur. Note that invocation of the completion handler does not
387387
* guarantee that the remote side has received all the bytes, only
388388
* that they have been written to the kernel. */
389-
public func writeData(_ data: NSData, timeout: NSTimeInterval, completionHandler: (NSError?) -> Void) { NSUnimplemented() }
389+
public func writeData(_ data: NSData, timeout: TimeInterval, completionHandler: (NSError?) -> Void) { NSUnimplemented() }
390390

391391
/* -captureStreams completes any already enqueued reads
392392
* and writes, and then invokes the
@@ -464,10 +464,10 @@ public class URLSessionConfiguration: NSObject, NSCopying {
464464
public var requestCachePolicy: NSURLRequest.CachePolicy
465465

466466
/* default timeout for requests. This will cause a timeout if no data is transmitted for the given timeout value, and is reset whenever data is transmitted. */
467-
public var timeoutIntervalForRequest: NSTimeInterval
467+
public var timeoutIntervalForRequest: TimeInterval
468468

469469
/* default timeout for requests. This will cause a timeout if a resource is not able to be retrieved within a given timeout. */
470-
public var timeoutIntervalForResource: NSTimeInterval
470+
public var timeoutIntervalForResource: TimeInterval
471471

472472
/* type of service for requests. */
473473
public var networkServiceType: URLRequest.NetworkServiceType

Foundation/URLRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct URLRequest : ReferenceConvertible, CustomStringConvertible, Equata
3333
/// - parameter: url The URL for the request.
3434
/// - parameter: cachePolicy The cache policy for the request. Defaults to `.useProtocolCachePolicy`
3535
/// - parameter: timeoutInterval The timeout interval for the request. See the commentary for the `timeoutInterval` for more information on timeout intervals. Defaults to 60.0
36-
public init(url: URL, cachePolicy: CachePolicy = .useProtocolCachePolicy, timeoutInterval: NSTimeInterval = 60.0) {
36+
public init(url: URL, cachePolicy: CachePolicy = .useProtocolCachePolicy, timeoutInterval: TimeInterval = 60.0) {
3737
_handle = _MutableHandle(adoptingReference: NSMutableURLRequest(url: url, cachePolicy: cachePolicy, timeoutInterval: timeoutInterval))
3838
}
3939

@@ -72,7 +72,7 @@ public struct URLRequest : ReferenceConvertible, CustomStringConvertible, Equata
7272
/// becomes greater than or equal to the timeout interval, the request
7373
/// is considered to have timed out. This timeout interval is measured
7474
/// in seconds.
75-
public var timeoutInterval: NSTimeInterval {
75+
public var timeoutInterval: TimeInterval {
7676
get {
7777
return _handle.map { $0.timeoutInterval }
7878
}

0 commit comments

Comments
 (0)