Skip to content

Commit a233682

Browse files
authored
Fix date encoding/decoding (#103)
1 parent 96b26a5 commit a233682

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.3...main)
4+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.4...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 1.2.4
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.3...1.2.4)
9+
10+
__Fixes__
11+
- Ensure all dates are encoded/decoded to the proper UTC time ([#103](https://github.com/parse-community/Parse-Swift/pull/103)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
### 1.2.3
814
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.2...1.2.3)
915

ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ struct GameScore: ParseObject {
1919
var updatedAt: Date?
2020
var ACL: ParseACL?
2121

22+
//: Your own properties.
2223
var score: Int?
24+
var timeStamp = Date()
2325
var oldScore: Int?
2426
}
2527

ParseSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ParseSwift"
3-
s.version = "1.2.3"
3+
s.version = "1.2.4"
44
s.summary = "Parse Pure Swift SDK"
55
s.homepage = "https://github.com/parse-community/Parse-Swift"
66
s.authors = {

ParseSwift.xcodeproj/project.pbxproj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,7 +2321,7 @@
23212321
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
23222322
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23232323
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2324-
MARKETING_VERSION = 1.2.3;
2324+
MARKETING_VERSION = 1.2.4;
23252325
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
23262326
PRODUCT_NAME = ParseSwift;
23272327
SKIP_INSTALL = YES;
@@ -2345,7 +2345,7 @@
23452345
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
23462346
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
23472347
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2348-
MARKETING_VERSION = 1.2.3;
2348+
MARKETING_VERSION = 1.2.4;
23492349
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
23502350
PRODUCT_NAME = ParseSwift;
23512351
SKIP_INSTALL = YES;
@@ -2411,7 +2411,7 @@
24112411
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24122412
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
24132413
MACOSX_DEPLOYMENT_TARGET = 10.13;
2414-
MARKETING_VERSION = 1.2.3;
2414+
MARKETING_VERSION = 1.2.4;
24152415
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24162416
PRODUCT_NAME = ParseSwift;
24172417
SDKROOT = macosx;
@@ -2437,7 +2437,7 @@
24372437
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
24382438
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
24392439
MACOSX_DEPLOYMENT_TARGET = 10.13;
2440-
MARKETING_VERSION = 1.2.3;
2440+
MARKETING_VERSION = 1.2.4;
24412441
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
24422442
PRODUCT_NAME = ParseSwift;
24432443
SDKROOT = macosx;
@@ -2584,7 +2584,7 @@
25842584
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
25852585
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
25862586
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2587-
MARKETING_VERSION = 1.2.3;
2587+
MARKETING_VERSION = 1.2.4;
25882588
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
25892589
MTL_FAST_MATH = YES;
25902590
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
@@ -2613,7 +2613,7 @@
26132613
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
26142614
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26152615
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2616-
MARKETING_VERSION = 1.2.3;
2616+
MARKETING_VERSION = 1.2.4;
26172617
MTL_FAST_MATH = YES;
26182618
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
26192619
PRODUCT_NAME = ParseSwift;
@@ -2640,7 +2640,7 @@
26402640
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
26412641
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26422642
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2643-
MARKETING_VERSION = 1.2.3;
2643+
MARKETING_VERSION = 1.2.4;
26442644
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
26452645
MTL_FAST_MATH = YES;
26462646
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
@@ -2668,7 +2668,7 @@
26682668
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
26692669
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
26702670
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
2671-
MARKETING_VERSION = 1.2.3;
2671+
MARKETING_VERSION = 1.2.4;
26722672
MTL_FAST_MATH = YES;
26732673
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
26742674
PRODUCT_NAME = ParseSwift;

Scripts/jazzy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bundle exec jazzy \
55
--author_url http://parseplatform.org \
66
--github_url https://github.com/parse-community/Parse-Swift \
77
--root-url http://parseplatform.org/Parse-Swift/api/ \
8-
--module-version 1.2.3 \
8+
--module-version 1.2.4 \
99
--theme fullwidth \
1010
--skip-undocumented \
1111
--output ./docs/api \

Sources/ParseSwift/Authentication/3rd Party/ParseFacebook.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public struct ParseFacebook<AuthenticatedUser: ParseUser>: ParseAuthentication {
4444
authenticationToken: String?,
4545
expirationDate: Date) -> [String: String] {
4646

47-
let dateString = DateFormatter.facebookDateFormatter.string(from: expirationDate)
47+
let dateString = ParseCoding.dateFormatter.string(from: expirationDate)
4848
var returnDictionary = [AuthenticationKeys.id.rawValue: userId,
4949
AuthenticationKeys.expirationDate.rawValue: dateString]
5050

@@ -356,14 +356,3 @@ public extension ParseUser {
356356
Self.facebook
357357
}
358358
}
359-
360-
// MARK: Convenience
361-
internal extension DateFormatter {
362-
static let facebookDateFormatter: DateFormatter = {
363-
var dateFormatter = DateFormatter()
364-
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
365-
dateFormatter.timeZone = TimeZone.init(secondsFromGMT: 0)
366-
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
367-
return dateFormatter
368-
}()
369-
}

Sources/ParseSwift/Coding/ParseCoding.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ extension ParseCoding {
4949

5050
static let dateFormatter: DateFormatter = {
5151
var dateFormatter = DateFormatter()
52-
dateFormatter.locale = Locale(identifier: "")
52+
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
53+
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
5354
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
5455
return dateFormatter
5556
}()

Tests/ParseSwiftTests/ParseFacebookTests.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,15 @@ class ParseFacebookTests: XCTestCase {
100100
accessToken: nil,
101101
authenticationToken: "authenticationToken",
102102
expirationDate: expirationDate)
103-
let dateString = DateFormatter
104-
.facebookDateFormatter
103+
let dateString = ParseCoding.dateFormatter
105104
.string(from: expirationDate)
106105
XCTAssertEqual(authData, ["id": "testing",
107106
"authenticationToken": "authenticationToken",
108107
"expirationDate": dateString])
109108
}
110109

111110
func testVerifyMandatoryKeys() throws {
112-
let dateString = DateFormatter.facebookDateFormatter.string(from: Date())
111+
let dateString = ParseCoding.dateFormatter.string(from: Date())
113112
let authData = ["id": "testing",
114113
"authenticationToken": "authenticationToken",
115114
"expirationDate": dateString]
@@ -127,7 +126,7 @@ class ParseFacebookTests: XCTestCase {
127126
accessToken: "accessToken",
128127
authenticationToken: nil,
129128
expirationDate: expirationDate)
130-
let dateString = DateFormatter.facebookDateFormatter.string(from: expirationDate)
129+
let dateString = ParseCoding.dateFormatter.string(from: expirationDate)
131130
XCTAssertEqual(authData, ["id": "testing", "accessToken": "accessToken", "expirationDate": dateString])
132131
}
133132

@@ -299,7 +298,7 @@ class ParseFacebookTests: XCTestCase {
299298
MockURLProtocol.removeAll()
300299

301300
let expectation1 = XCTestExpectation(description: "Login")
302-
let currentDate = DateFormatter.facebookDateFormatter.string(from: Date())
301+
let currentDate = ParseCoding.dateFormatter.string(from: Date())
303302
let authData = ["id": "hello",
304303
"expirationDate": currentDate]
305304
User.facebook.login(authData: authData) { result in
@@ -682,7 +681,7 @@ class ParseFacebookTests: XCTestCase {
682681
MockURLProtocol.removeAll()
683682

684683
let expectation1 = XCTestExpectation(description: "Login")
685-
let currentDate = DateFormatter.facebookDateFormatter.string(from: Date())
684+
let currentDate = ParseCoding.dateFormatter.string(from: Date())
686685
let authData = ["id": "hello",
687686
"expirationDate": currentDate]
688687
User.facebook.link(authData: authData) { result in

0 commit comments

Comments
 (0)