Skip to content

Commit 8955678

Browse files
committed
Fixes for NSDateFormatter
1 parent fae5a12 commit 8955678

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Foundation/NSDateFormatter.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class NSDateFormatter : NSFormatter {
2323
#endif
2424
let obj = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale._cfObject, dateStyle, timeStyle)
2525
// TODO: Set up attributes here
26+
if let dateFormat = _dateFormat {
27+
CFDateFormatterSetFormat(obj, dateFormat._cfObject)
28+
}
2629
__cfObject = obj
2730
return obj
2831
}
@@ -51,7 +54,7 @@ public class NSDateFormatter : NSFormatter {
5154
}
5255

5356
public func dateFromString(string: String) -> NSDate? {
54-
var range = CFRange()
57+
var range = CFRange(location: 0, length: string.length)
5558
let date = withUnsafeMutablePointer(&range) { (rangep: UnsafeMutablePointer<CFRange>) -> NSDate? in
5659
guard let res = CFDateFormatterCreateDateFromString(kCFAllocatorSystemDefault, _cfObject, string._cfObject, rangep) else {
5760
return nil

Foundation/NSNumberFormatter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class NSNumberFormatter : NSFormatter {
5959
}
6060

6161
public func numberFromString(string: String) -> NSNumber? {
62-
var range = CFRange()
62+
var range = CFRange(location: 0, length: string.length)
6363
let number = withUnsafeMutablePointer(&range) { (rangePointer: UnsafeMutablePointer<CFRange>) -> NSNumber? in
6464

6565
#if os(OSX) || os(iOS)

0 commit comments

Comments
 (0)