@@ -226,30 +226,15 @@ extension NSDate {
226
226
}
227
227
}
228
228
229
- extension NSDate : _SwiftBridgeable {
230
- typealias SwiftType = Date
231
- var _swiftObject : Date {
232
- return Date ( timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate)
229
+ extension Date : CustomPlaygroundDisplayConvertible {
230
+ public var playgroundDescription : Any {
231
+ let df = DateFormatter ( )
232
+ df. dateStyle = . medium
233
+ df. timeStyle = . short
234
+ return df. string ( from: self )
233
235
}
234
236
}
235
237
236
- extension CFDate : _NSBridgeable , _SwiftBridgeable {
237
- typealias NSType = NSDate
238
- typealias SwiftType = Date
239
-
240
- internal var _nsObject : NSType { return unsafeBitCast ( self , to: NSType . self) }
241
- internal var _swiftObject : Date { return _nsObject. _swiftObject }
242
- }
243
-
244
- extension Date : _NSBridgeable {
245
- typealias NSType = NSDate
246
- typealias CFType = CFDate
247
-
248
- internal var _nsObject : NSType { return NSDate ( timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate) }
249
- internal var _cfObject : CFType { return _nsObject. _cfObject }
250
- }
251
-
252
-
253
238
open class NSDateInterval : NSObject , NSCopying , NSSecureCoding {
254
239
255
240
@@ -407,6 +392,8 @@ open class NSDateInterval : NSObject, NSCopying, NSSecureCoding {
407
392
}
408
393
}
409
394
395
+ // MARK: - Bridging
396
+
410
397
extension NSDate : _StructTypeBridgeable {
411
398
public typealias _StructType = Date
412
399
@@ -429,3 +416,49 @@ extension NSDateInterval : _SwiftBridgeable {
429
416
}
430
417
}
431
418
419
+ extension NSDate : _SwiftBridgeable {
420
+ typealias SwiftType = Date
421
+ var _swiftObject : Date {
422
+ return Date ( timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate)
423
+ }
424
+ }
425
+
426
+ extension CFDate : _NSBridgeable , _SwiftBridgeable {
427
+ typealias NSType = NSDate
428
+ typealias SwiftType = Date
429
+
430
+ internal var _nsObject : NSType { return unsafeBitCast ( self , to: NSType . self) }
431
+ internal var _swiftObject : Date { return _nsObject. _swiftObject }
432
+ }
433
+
434
+ extension Date : _NSBridgeable {
435
+ typealias NSType = NSDate
436
+ typealias CFType = CFDate
437
+
438
+ internal var _nsObject : NSType { return NSDate ( timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate) }
439
+ internal var _cfObject : CFType { return _nsObject. _cfObject }
440
+ }
441
+
442
+ extension Date : _ObjectiveCBridgeable {
443
+ @_semantics ( " convertToObjectiveC " )
444
+ public func _bridgeToObjectiveC( ) -> NSDate {
445
+ return NSDate ( timeIntervalSinceReferenceDate: timeIntervalSinceReferenceDate)
446
+ }
447
+
448
+ public static func _forceBridgeFromObjectiveC( _ x: NSDate , result: inout Date ? ) {
449
+ if !_conditionallyBridgeFromObjectiveC( x, result: & result) {
450
+ fatalError ( " Unable to bridge \( NSDate . self) to \( self ) " )
451
+ }
452
+ }
453
+
454
+ public static func _conditionallyBridgeFromObjectiveC( _ x: NSDate , result: inout Date ? ) -> Bool {
455
+ result = Date ( timeIntervalSinceReferenceDate: x. timeIntervalSinceReferenceDate)
456
+ return true
457
+ }
458
+
459
+ public static func _unconditionallyBridgeFromObjectiveC( _ source: NSDate ? ) -> Date {
460
+ var result : Date ? = nil
461
+ _forceBridgeFromObjectiveC ( source!, result: & result)
462
+ return result!
463
+ }
464
+ }
0 commit comments