Skip to content

Commit

Permalink
feat: timestamp to iso string format
Browse files Browse the repository at this point in the history
  • Loading branch information
JNdhlovu committed Feb 3, 2025
1 parent c1b312c commit 2b0483d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Sources/SmileID/Classes/Helpers/DateUtils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extension Date {
/// Converts Date to ISO8601 string with millisecond precision in UTC timezone
/// Format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z' (e.g. 2025-02-03T12:34:56.789Z)
internal func toISO8601WithMilliseconds() -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
formatter.timeZone = TimeZone(abbreviation: "UTC")
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter.string(from: self)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public struct ProductsConfigRequest: Encodable {

public init() {
partnerId = SmileID.config.partnerId
timestamp = String(Int(Date().timeIntervalSince1970 * 1000))
timestamp = Date().toISO8601WithMilliseconds()
signature = try? calculateSignature(timestamp: timestamp)
}

Expand Down

0 comments on commit 2b0483d

Please sign in to comment.