Skip to content

Commit 766f2f5

Browse files
committed
Fix CI
1 parent 0a83524 commit 766f2f5

5 files changed

Lines changed: 26 additions & 26 deletions

File tree

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ jobs:
99
strategy:
1010
matrix:
1111
os:
12-
- ubuntu-latest
1312
- macOS-latest
13+
- ubuntu-latest
1414
runs-on: ${{ matrix.os }}
1515
steps:
16-
- uses: actions/checkout@v1
16+
- uses: actions/checkout@v2
1717
- run: rm .swift-version
1818
- name: Install Swift
19-
uses: YOCKOW/Action-setup-swift@master
19+
uses: YOCKOW/Action-setup-swift@v1
2020
with:
21-
swift-version: '5.1'
21+
swift-version: '5.9'
2222
- name: Test
2323
run: swift test --enable-test-discovery

Sources/DictionaryDecoder.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,10 @@ import Foundation
1111

1212
open class DictionaryDecoder: Decoder {
1313
open var codingPath: [CodingKey]
14-
open var dateDecodingStrategy: DateDecodingStrategy = .deferredToDate
14+
open var dateDecodingStrategy = JSONDecoder.DateDecodingStrategy.deferredToDate
1515
open var userInfo: [CodingUserInfoKey: Any] = [:]
1616
var storage = Storage()
1717

18-
public enum DateDecodingStrategy {
19-
case deferredToDate
20-
case secondsSince1970
21-
case millisecondsSince1970
22-
case iso8601
23-
case formatted(DateFormatter)
24-
case custom((_ decoder: Decoder) throws -> Date)
25-
}
26-
2718
public init() {
2819
codingPath = []
2920
}

Sources/DictionaryEncoder.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,10 @@ import Foundation
1010

1111
open class DictionaryEncoder: Encoder {
1212
open var codingPath: [CodingKey] = []
13-
open var dateEncodingStrategy: DateEncodingStrategy = .deferredToDate
13+
open var dateEncodingStrategy = JSONEncoder.DateEncodingStrategy.deferredToDate
1414
open var userInfo: [CodingUserInfoKey: Any] = [:]
1515
private(set) var storage = Storage()
1616

17-
public enum DateEncodingStrategy {
18-
case deferredToDate
19-
case secondsSince1970
20-
case millisecondsSince1970
21-
case iso8601
22-
case formatted(DateFormatter)
23-
case custom((Date, Encoder) throws -> Void)
24-
}
25-
2617
public init() {}
2718

2819
open func container<Key: CodingKey>(keyedBy type: Key.Type) -> KeyedEncodingContainer<Key> {

Tests/DictionaryDecoderTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DictionaryDecoderTests: XCTestCase {
8080
decoder.dateDecodingStrategy = .millisecondsSince1970
8181
XCTAssertEqual(try decoder.decode(Model.self, from: ["date": date.timeIntervalSince1970 * 1000]), Model(date: date, optionalDate: nil))
8282

83-
if #available(iOS 15.0, *) {
83+
if #available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) {
8484
decoder.dateDecodingStrategy = .iso8601
8585
XCTAssertEqual(try decoder.decode(Model.self, from: ["date": date.ISO8601Format()]), Model(date: date, optionalDate: nil))
8686
}
@@ -101,3 +101,12 @@ class DictionaryDecoderTests: XCTestCase {
101101
XCTAssertEqual(try decoder.decode(Model.self, from: ["date": 13]), Model(date: date, optionalDate: nil))
102102
}
103103
}
104+
105+
#if os(Linux)
106+
private extension Date {
107+
func ISO8601Format() -> String {
108+
let formatter = ISO8601DateFormatter()
109+
return formatter.string(from: self)
110+
}
111+
}
112+
#endif

Tests/DictionaryEncoderTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class DictionaryEncoderTests: XCTestCase {
164164
XCTAssertEqual(dictionary["optionalDate"] as? TimeInterval, seed.model.optionalDate.map { $0.timeIntervalSince1970 * 1000 })
165165
XCTAssertEqual(dictionary.keys.count, seed.count)
166166

167-
if #available(iOS 15.0, *) {
167+
if #available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) {
168168
encoder.dateEncodingStrategy = .iso8601
169169
dictionary = try encoder.encode(seed.model)
170170
XCTAssertEqual(dictionary["date"] as? String, seed.model.date.ISO8601Format())
@@ -193,3 +193,12 @@ class DictionaryEncoderTests: XCTestCase {
193193
}
194194
}
195195
}
196+
197+
#if os(Linux)
198+
private extension Date {
199+
func ISO8601Format() -> String {
200+
let formatter = ISO8601DateFormatter()
201+
return formatter.string(from: self)
202+
}
203+
}
204+
#endif

0 commit comments

Comments
 (0)