Skip to content

Commit

Permalink
Merge pull request #553 from Kemmey/DateFormatMSecNoZ
Browse files Browse the repository at this point in the history
Support for date format with milliseconds but no Z terminator
  • Loading branch information
3lvis committed Jan 16, 2019
2 parents 51fa256 + b63125f commit c74f903
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/DateParser/NSDate+PropertyMapper.m
Expand Up @@ -107,6 +107,15 @@ + (NSDate *)dateFromISO8601String:(NSString *)dateString {
hasCentiseconds = YES;
}

// Copy all the date excluding the miliseconds.
// Current date: 2017-12-22T18:10:14.070
// Will become: 2017-12-22T18:10:14
// Unit test O
else if (originalLength == 23 && originalString[originalLength - 1] != 'Z') {
strncpy(currentString, originalString, 19);
hasMiliseconds = YES;
}

// Copy all the date excluding the miliseconds and the Z.
// Current date: 2017-11-02T17:27:52.2Z
// Will become: 2014-03-30T09:13:00
Expand Down
8 changes: 8 additions & 0 deletions Tests/DateParser/DateTests.swift
Expand Up @@ -108,6 +108,14 @@ class DateTests: XCTestCase {
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

func testDateO() {
let date = Date.dateWithHourAndTimeZoneString(dateString: "2017-12-22T18:10:14.070")
let resultDate = NSDate(fromDateString: "2017-12-22T18:10:14.070")! as Date
XCTAssertNotNil(resultDate)
XCTAssertEqual(date, resultDate)
}

}

class TimestampDateTests: XCTestCase {
Expand Down

0 comments on commit c74f903

Please sign in to comment.