Skip to content

Commit

Permalink
Merge pull request #22 from auth0/bugfix-date-format
Browse files Browse the repository at this point in the history
Correct new format of the date according to API
  • Loading branch information
hzalaz committed Jun 9, 2016
2 parents 552d697 + 3736143 commit 3848de9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Auth0/Authentication/UserProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public class UserProfile: NSObject, JSONObjectPayload {
private func fromSO8601(string: String) -> NSDate? {
let formatter = NSDateFormatter()
formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ"
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
formatter.timeZone = NSTimeZone(name: "UTC")
return formatter.dateFromString(string)
}
2 changes: 1 addition & 1 deletion Auth0Tests/Authentication/UserProfileSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UserProfileSpec: QuickSpec {
expect(profile?.name) == Support
expect(profile?.nickname) == Nickname
expect(profile?.pictureURL) == PictureURL
expect(profile?.createdAt) == dateFromISODate(CreatedAt)
expect(profile?.createdAt.timeIntervalSince1970) == CreatedAtTimestamp
expect(profile?.identities).to(beEmpty())
}

Expand Down
10 changes: 2 additions & 8 deletions Auth0Tests/Utils/Responses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@ let Support = "support"
let Auth0Phone = "+10123456789"
let Nickname = "sup"
let PictureURL = NSURL(string: "https://auth0.com")!
let CreatedAt = "2016-04-27T17:59:00Z"

func dateFromISODate(string: String) -> NSDate {
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ"
return dateFormatter.dateFromString(string)!
}
let CreatedAt = "2015-08-19T17:18:00.123Z"
let CreatedAtTimestamp = 1440004680.123

func authResponse(accessToken accessToken: String, idToken: String? = nil) -> OHHTTPStubsResponse {
var json = [
Expand Down
2 changes: 2 additions & 0 deletions OAuth2/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down

0 comments on commit 3848de9

Please sign in to comment.