diff --git a/Source/DateParser/NSDate+PropertyMapper.m b/Source/DateParser/NSDate+PropertyMapper.m index f65c7e52..24ef25f7 100755 --- a/Source/DateParser/NSDate+PropertyMapper.m +++ b/Source/DateParser/NSDate+PropertyMapper.m @@ -97,6 +97,15 @@ + (NSDate *)dateFromISO8601String:(NSString *)dateString { hasMiliseconds = YES; } + // Copy all the date excluding the miliseconds and the Z. + // Current date: 2017-12-22T18:10:14.07Z + // Will become: 2014-03-30T09:13:00 + // Unit test M + else if (originalLength == 23 && originalString[originalLength - 1] == 'Z') { + strncpy(currentString, originalString, 19); + hasCentiseconds = YES; + } + // Copy all the date excluding the miliseconds and the timezone also set `hasTimezone` to YES. // Current date: 2015-06-23T12:40:08.000+02:00 // Will become: 2015-06-23T12:40:08 diff --git a/Tests/DateParser/DateTests.swift b/Tests/DateParser/DateTests.swift index 9abcd375..29b7f013 100755 --- a/Tests/DateParser/DateTests.swift +++ b/Tests/DateParser/DateTests.swift @@ -94,6 +94,13 @@ class DateTests: XCTestCase { XCTAssertNotNil(resultDate) XCTAssertEqual(date, resultDate) } + + func testDateM() { + let date = Date.dateWithHourAndTimeZoneString(dateString: "2017-12-22T18:10:14.070") + let resultDate = NSDate(fromDateString: "2017-12-22T18:10:14.07Z")! as Date + XCTAssertNotNil(resultDate) + XCTAssertEqual(date, resultDate) + } } class TimestampDateTests: XCTestCase {