Skip to content

Commit

Permalink
Merge pull request #533 from 3lvis/fix/date-centiseconds-issue-532
Browse files Browse the repository at this point in the history
Fix for date with centiseconds
  • Loading branch information
3lvis authored Sep 13, 2018
2 parents 338a1bd + e80f387 commit 0f39cb8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Source/DateParser/NSDate+PropertyMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions Tests/DateParser/DateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0f39cb8

Please sign in to comment.