Skip to content

Commit 87dba77

Browse files
committed
fix recorded_at
1 parent 8cabad5 commit 87dba77

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

StudyplusSDK/StudyplusRecord.swift

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ private let formatter: DateFormatter = {
3434
return f
3535
}()
3636

37+
fileprivate enum DateLocalePattern {
38+
case current
39+
case enUSPOSIX
40+
41+
var value: Locale {
42+
switch self {
43+
case .current:
44+
return Locale.current
45+
case .enUSPOSIX:
46+
return Locale(identifier: "en_US_POSIX")
47+
}
48+
}
49+
}
50+
3751
private extension Date {
3852

3953
init?(dateString: String, dateFormat: String = "yyyy-MM-dd'T'HH:mm:ssZ") {
@@ -42,8 +56,8 @@ private extension Date {
4256
self = date
4357
}
4458

45-
func string(format: String = "yyyy-MM-dd'T'HH:mm:ssZ") -> String {
46-
formatter.locale = Locale.current
59+
func string(format: String = "yyyy-MM-dd'T'HH:mm:ssZ", locale: DateLocalePattern) -> String {
60+
formatter.locale = locale.value
4761
formatter.dateFormat = format
4862
return formatter.string(from: self)
4963
}
@@ -109,7 +123,7 @@ public struct StudyplusRecord {
109123
var params: [String: Any] = [:]
110124

111125
params["duration"] = NSNumber(value: self.duration)
112-
params["recorded_at"] = self.recordedAt.string(format: "yyyy-MM-dd HH:mm:ss")
126+
params["recorded_at"] = self.recordedAt.string(format: "yyyy-MM-dd HH:mm:ss", locale: .enUSPOSIX)
113127

114128
if let comment = self.comment {
115129
params["comment"] = comment

0 commit comments

Comments
 (0)