@@ -72,15 +72,51 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
7272 public func encodeWithCoder( aCoder: NSCoder ) {
7373
7474 }
75-
75+
76+ /**
77+ A string representation of the date object (read-only).
78+
79+ The representation is useful for debugging only.
80+
81+ There are a number of options to acquire a formatted string for a date
82+ including: date formatters (see
83+ [NSDateFormatter](//apple_ref/occ/cl/NSDateFormatter) and
84+ [Data Formatting Guide](//apple_ref/doc/uid/10000029i)),
85+ and the `NSDate` methods `descriptionWithLocale:`,
86+ `dateWithCalendarFormat:timeZone:`, and
87+ `descriptionWithCalendarFormat:timeZone:locale:`.
88+ */
7689 public override var description : String {
7790 get {
78- return CFCopyDescription ( _cfObject) . _swiftObject
91+ let dateFormatterRef = CFDateFormatterCreate ( kCFAllocatorSystemDefault, nil , kCFDateFormatterFullStyle, kCFDateFormatterFullStyle)
92+ let timeZone = CFTimeZoneCreateWithTimeIntervalFromGMT ( kCFAllocatorSystemDefault, 0.0 )
93+ CFDateFormatterSetProperty ( dateFormatterRef, kCFDateFormatterTimeZoneKey, timeZone)
94+ CFDateFormatterSetFormat ( dateFormatterRef, " uuuu-MM-dd HH:mm:ss '+0000' " . _cfObject)
95+
96+ return CFDateFormatterCreateStringWithDate ( kCFAllocatorSystemDefault, dateFormatterRef, _cfObject) . _swiftObject
7997 }
8098 }
81-
99+
100+ /**
101+ Returns a string representation of the receiver using the given locale.
102+
103+ - Parameter locale: An `NSLocale` object.
104+
105+ If you pass `nil`, `NSDate` formats the date in the same way as the
106+ `description` property.
107+
108+ - Returns: A string representation of the receiver, using the given locale,
109+ or if the locale argument is `nil`, in the international format
110+ `YYYY-MM-DD HH:MM:SS ±HHMM`, where `±HHMM` represents the time zone
111+ offset in hours and minutes from UTC (for example,
112+ "2001-03-24 10:45:32 +0600")
113+ */
82114 public func descriptionWithLocale( locale: AnyObject ? ) -> String {
83- return description
115+ guard let aLocale = locale else { return description }
116+ let dateFormatterRef = CFDateFormatterCreate ( kCFAllocatorSystemDefault, ( aLocale as! NSLocale ) . _cfObject, kCFDateFormatterFullStyle, kCFDateFormatterFullStyle)
117+ CFDateFormatterSetProperty ( dateFormatterRef, kCFDateFormatterTimeZoneKey, CFTimeZoneCopySystem ( ) )
118+
119+ return CFDateFormatterCreateStringWithDate ( kCFAllocatorSystemDefault, dateFormatterRef, _cfObject) . _swiftObject
84120 }
85121
86122 override internal var _cfTypeID : CFTypeID {
0 commit comments