Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct RFC3339Strategy: DateValueCodableStrategy {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"
Comment thread
coderabbitai[bot] marked this conversation as resolved.
return dateFormatter
}()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// RFC3339StrategyEncodingTests.swift
// KarrotCodableKit
//
// Created by Elon on 7/13/26.
//

import XCTest

import KarrotCodableKit

final class RFC3339StrategyEncodingTests: XCTestCase {
func testEncodingUTCDateUsesStandardCompliantOffset() throws {
// given
let date = Date(timeIntervalSince1970: 1715082540) // 2024-05-07T11:49:00 UTC

// when
let result = RFC3339Strategy.encode(date)

// then
// RFC 3339 requires the UTC offset to be "Z" (or "+00:00"), not the colon-less "+0000".
XCTAssertEqual(result, "2024-05-07T11:49:00Z")
}
}
Loading