From 520b7291234c5a3a987a93649e7a3b9ed574b166 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Tue, 3 Jan 2017 23:29:07 +0100 Subject: [PATCH] - Fix NSDate parsing --- Example/Podfile.lock | 4 ++-- Example/Pods/Local Podspecs/PNObject.podspec.json | 4 ++-- Example/Pods/Manifest.lock | 4 ++-- PNObject.podspec | 2 +- PNObject/Classes/PNObject+Protected.m | 8 +++++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 73e1e0f..1dd30db 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -37,7 +37,7 @@ PODS: - NSString-Helper (1.0.5) - nv-ios-http-status (0.0.1) - PEAR-FileManager-iOS (1.3.1) - - PNObject (1.1.0): + - PNObject (1.1.1): - AFNetworking - CodFis-Helper - DDDKeychainWrapper @@ -84,7 +84,7 @@ SPEC CHECKSUMS: NSString-Helper: 459e1b6a62b3bf7db10f01b0d102548608e945c4 nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 - PNObject: 527e0ee690cabcb15a793a0b78336e65b126aaf5 + PNObject: f38657e6b3e643f397da970c9e454bd2991b5b94 PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd RZDataBinding: 6981e90ddaae2f5e02028323b1043f8c31013109 Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 diff --git a/Example/Pods/Local Podspecs/PNObject.podspec.json b/Example/Pods/Local Podspecs/PNObject.podspec.json index aa4f468..651bd52 100644 --- a/Example/Pods/Local Podspecs/PNObject.podspec.json +++ b/Example/Pods/Local Podspecs/PNObject.podspec.json @@ -1,6 +1,6 @@ { "name": "PNObject", - "version": "1.1.0", + "version": "1.1.1", "summary": "PNObject is a simple replica of the more complex ParseObject", "homepage": "https://git.giuseppenucifora.com/giuseppenucifora/PNObject", "license": { @@ -12,7 +12,7 @@ }, "source": { "git": "https://git.giuseppenucifora.com/giuseppenucifora/PNObject.git", - "tag": "1.1.0" + "tag": "1.1.1" }, "platforms": { "ios": "8.0" diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 73e1e0f..1dd30db 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -37,7 +37,7 @@ PODS: - NSString-Helper (1.0.5) - nv-ios-http-status (0.0.1) - PEAR-FileManager-iOS (1.3.1) - - PNObject (1.1.0): + - PNObject (1.1.1): - AFNetworking - CodFis-Helper - DDDKeychainWrapper @@ -84,7 +84,7 @@ SPEC CHECKSUMS: NSString-Helper: 459e1b6a62b3bf7db10f01b0d102548608e945c4 nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3 - PNObject: 527e0ee690cabcb15a793a0b78336e65b126aaf5 + PNObject: f38657e6b3e643f397da970c9e454bd2991b5b94 PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd RZDataBinding: 6981e90ddaae2f5e02028323b1043f8c31013109 Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2 diff --git a/PNObject.podspec b/PNObject.podspec index 2e9279a..0fd1dbc 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'PNObject' -s.version = '1.1.0' +s.version = '1.1.1' s.summary = 'PNObject is a simple replica of the more complex ParseObject' diff --git a/PNObject/Classes/PNObject+Protected.m b/PNObject/Classes/PNObject+Protected.m index 567448a..6c136a1 100644 --- a/PNObject/Classes/PNObject+Protected.m +++ b/PNObject/Classes/PNObject+Protected.m @@ -118,7 +118,13 @@ }, @"NSDate" : ^{ NSString *str = [NSString stringWithFormat:@"%@", value]; - NSDate *val = [[NSDate dateFromString:str withFormat:kNSDateHelperFormatSQLDateWithTime] toLocalTime]; + NSString *dateFormat = [NSDate parseDateFormatFromString:str]; + + if (dateFormat == nil) { + dateFormat = kNSDateHelperFormatSQLDateWithTime; + } + + NSDate *val = [[NSDate dateFromString:str withFormat:dateFormat] toLocalTime]; if (![self isObjNull:val]) { [self setValue:val forKey:propertyName]; }