Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for date with centiseconds #533

Merged
merged 1 commit into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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