diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3601aa2..c5ce056 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: apple: if: github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip ci]') name: ${{ matrix.platform }} (Swift ${{ matrix.swift }}) - runs-on: macos-15 + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: @@ -46,9 +46,13 @@ jobs: - watchOS - visionOS swift: - - "6.0" - "6.1" - "6.2" + include: + - swift: "6.1" + runner: macos-15 + - swift: "6.2" + runner: macos-26 steps: - name: Git Checkout uses: actions/checkout@v5 @@ -88,7 +92,6 @@ jobs: fail-fast: false matrix: swift: - - "6.0" - "6.1" - "6.2" container: @@ -107,7 +110,6 @@ jobs: fail-fast: false matrix: swift: - - "6.0" - "6.1" - "6.2" steps: @@ -118,6 +120,4 @@ jobs: uses: skiptools/swift-android-action@v2 with: swift-version: ${{ matrix.swift }} - build-tests: ${{ matrix.swift != '6.0' }} - run-tests: ${{ matrix.swift != '6.0' }} free-disk-space: true diff --git a/.swift-version b/.swift-version index e0ea36f..a435f5a 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -6.0 +6.1 diff --git a/Package.resolved b/Package.resolved index e3b7376..16de199 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "19c1dbe5af5c4e70b36063f413197273c689e9b361ec7235066c9e0dc8c68903", + "originHash" : "68d4ae9498eac8062a7efc2b0d381a4fe3b2fc999f49f32b5eeb823e31332f78", "pins" : [ { "identity" : "swift-argument-parser", @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump", "state" : { - "revision" : "93a8aa4937030b606de42f44b17870249f49af0b", - "version" : "1.3.4" + "revision" : "2a2a938798236b8fa0bc57c453ee9de9f9ec3ab0", + "version" : "1.4.1" } }, { @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay", "state" : { - "revision" : "34e463e98ab8541c604af706c99bed7160f5ec70", - "version" : "1.8.1" + "revision" : "dfd70507def84cb5fb821278448a262c6ff2bbad", + "version" : "1.9.0" } } ], diff --git a/Package.swift b/Package.swift index 2a85f85..c8007f0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:6.0 +// swift-tools-version: 6.1 import PackageDescription @@ -6,8 +6,10 @@ let package = Package( name: "Period", platforms: [ .iOS(.v15), + .macCatalyst(.v15), .macOS(.v12), .tvOS(.v15), + .visionOS(.v1), .watchOS(.v8), ], products: [ @@ -21,7 +23,7 @@ let package = Package( "Period", .product(name: "JSONTesting", package: "swift-json-testing"), ], - path: "Tests" + path: "Tests", ), .executableTarget( @@ -29,12 +31,20 @@ let package = Package( dependencies: [ "Period", .product(name: "Benchmark", package: "swift-benchmark"), - ] + ], ), - ] + ], ) -package.dependencies = [ +package.dependencies += [ .package(url: "https://github.com/google/swift-benchmark", from: "0.1.2"), .package(url: "https://github.com/davdroman/swift-json-testing", from: "0.2.0"), ] + +for target in package.targets { + target.swiftSettings = target.swiftSettings ?? [] + target.swiftSettings? += [ + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("InternalImportsByDefault"), + ] +} diff --git a/Sources/Period/Arithmetic.swift b/Sources/Period/Arithmetic.swift index d549259..c3a7cc0 100644 --- a/Sources/Period/Arithmetic.swift +++ b/Sources/Period/Arithmetic.swift @@ -12,7 +12,7 @@ extension Period { days: -rhs.days, hours: -rhs.hours, minutes: -rhs.minutes, - seconds: -rhs.seconds + seconds: -rhs.seconds, ) } @@ -25,7 +25,7 @@ extension Period { days: lhs.days + rhs.days, hours: lhs.hours + rhs.hours, minutes: lhs.minutes + rhs.minutes, - seconds: lhs.seconds + rhs.seconds + seconds: lhs.seconds + rhs.seconds, ) } @@ -42,7 +42,7 @@ extension Period { days: lhs.days - rhs.days, hours: lhs.hours - rhs.hours, minutes: lhs.minutes - rhs.minutes, - seconds: lhs.seconds - rhs.seconds + seconds: lhs.seconds - rhs.seconds, ) } @@ -59,7 +59,7 @@ extension Period { days: lhs.days * rhs, hours: lhs.hours * rhs, minutes: lhs.minutes * rhs, - seconds: lhs.seconds * rhs + seconds: lhs.seconds * rhs, ) } diff --git a/Sources/Period/Calendar.swift b/Sources/Period/Calendar.swift index c76f513..1e8337f 100644 --- a/Sources/Period/Calendar.swift +++ b/Sources/Period/Calendar.swift @@ -1,4 +1,4 @@ -import Foundation +public import Foundation extension Calendar { public func date(byAdding period: Period, to date: Date, wrappingComponents: Bool = false) -> Date? { @@ -13,7 +13,7 @@ extension Calendar { days: components.day ?? 0, hours: components.hour ?? 0, minutes: components.minute ?? 0, - seconds: components.second ?? 0 + seconds: components.second ?? 0, ) } } @@ -26,7 +26,7 @@ extension DateComponents { day: period.days, hour: period.hours, minute: period.minutes, - second: period.seconds + second: period.seconds, ) } } diff --git a/Sources/Period/Codable.swift b/Sources/Period/Codable.swift index 2d50f9b..f39c26b 100644 --- a/Sources/Period/Codable.swift +++ b/Sources/Period/Codable.swift @@ -1,7 +1,7 @@ import Foundation extension Period: Codable { - public init(from decoder: Decoder) throws { + public init(from decoder: any Decoder) throws { let container = try decoder.singleValueContainer() let rawValue = try container.decode(String.self) do { @@ -9,12 +9,12 @@ extension Period: Codable { } catch { throw DecodingError.dataCorruptedError( in: container, - debugDescription: "Invalid ISO 8601 duration \"\(rawValue)\"" + debugDescription: "Invalid ISO 8601 duration \"\(rawValue)\"", ) } } - public func encode(to encoder: Encoder) throws { + public func encode(to encoder: any Encoder) throws { var container = encoder.singleValueContainer() try container.encode(self.formatted(.iso8601)) } diff --git a/Sources/Period/Formatting.swift b/Sources/Period/Formatting.swift index 190cdff..027b4a5 100644 --- a/Sources/Period/Formatting.swift +++ b/Sources/Period/Formatting.swift @@ -1,5 +1,5 @@ #if canImport(Darwin) -import Foundation +public import Foundation extension Period { public struct FormatStyle: Foundation.FormatStyle, Sendable { diff --git a/Sources/Period/ISO8601.swift b/Sources/Period/ISO8601.swift index b9dec02..ef0b8ea 100644 --- a/Sources/Period/ISO8601.swift +++ b/Sources/Period/ISO8601.swift @@ -1,4 +1,4 @@ -import Foundation +public import Foundation extension Period { public struct ISO8601FormatStyle: ParseableFormatStyle, ParseStrategy { @@ -41,7 +41,7 @@ extension Period { enum Parser { static let regex = try! NSRegularExpression( - pattern: #"([+-])?P(?:(-?\d+)?Y)?(?:(-?\d+)?M)?(?:(-?\d+)?W)?(?:(-?\d+)?D)?(?:T(?:(-?\d+)?H)?(?:(-?\d+)?M)?(?:(-?\d+)?S)?)?"# + pattern: #"([+-])?P(?:(-?\d+)?Y)?(?:(-?\d+)?M)?(?:(-?\d+)?W)?(?:(-?\d+)?D)?(?:T(?:(-?\d+)?H)?(?:(-?\d+)?M)?(?:(-?\d+)?S)?)?"#, ) static func parse(_ string: String) -> Period? { @@ -94,7 +94,7 @@ extension Period { days: ((weeks ?? 0) * 7 + (days ?? 0)) * leadingSign, hours: (hours ?? 0) * leadingSign, minutes: (minutes ?? 0) * leadingSign, - seconds: (seconds ?? 0) * leadingSign + seconds: (seconds ?? 0) * leadingSign, ) } } diff --git a/Sources/Period/Period.swift b/Sources/Period/Period.swift index 3c769f2..857fe10 100644 --- a/Sources/Period/Period.swift +++ b/Sources/Period/Period.swift @@ -14,7 +14,7 @@ public struct Period: Hashable, Sendable { days: Int = 0, hours: Int = 0, minutes: Int = 0, - seconds: Int = 0 + seconds: Int = 0, ) { self.years = years self.months = months diff --git a/Tests/DescriptionTests.swift b/Tests/DescriptionTests.swift index fcfa0f8..d81a050 100644 --- a/Tests/DescriptionTests.swift +++ b/Tests/DescriptionTests.swift @@ -5,15 +5,15 @@ struct DescriptionTests { @Test func periodDescription() { #expect( Period.zero.description - == "" + == "", ) #expect( Period(years: 1, months: 1, days: 1, hours: 1, minutes: 1, seconds: 1).description - == "1 year, 1 month, 1 day, 1 hour, 1 minute, 1 second" + == "1 year, 1 month, 1 day, 1 hour, 1 minute, 1 second", ) #expect( Period(years: 3, months: 3, days: 3, hours: 3, minutes: 3, seconds: 3).description - == "3 years, 3 months, 3 days, 3 hours, 3 minutes, 3 seconds" + == "3 years, 3 months, 3 days, 3 hours, 3 minutes, 3 seconds", ) } } diff --git a/Tests/FormattingTests.swift b/Tests/FormattingTests.swift index cf1db6e..4d2fa6e 100644 --- a/Tests/FormattingTests.swift +++ b/Tests/FormattingTests.swift @@ -12,11 +12,11 @@ extension FormattingTests { @Test func periodFormatting_defaultStyle() { #expect( Period.zero.formatted(.full.locale(enLocale)) - == "0 seconds" + == "0 seconds", ) #expect( Period(years: 1, months: 2, days: 3, hours: 4, minutes: 5, seconds: 6).formatted(.full.locale(enLocale)) - == "1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds" + == "1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds", ) } } @@ -25,11 +25,11 @@ extension FormattingTests { @Test func periodFormatting_explicitStyle() { #expect( Period.zero.formatted(.short.locale(enLocale)) - == "0 secs" + == "0 secs", ) #expect( Period(years: 1, months: 2, days: 3, hours: 4, minutes: 5, seconds: 6).formatted(.short.locale(enLocale)) - == "1 yr, 2 mths, 3 days, 4 hrs, 5 min, 6 secs" + == "1 yr, 2 mths, 3 days, 4 hrs, 5 min, 6 secs", ) } } @@ -38,11 +38,11 @@ extension FormattingTests { @Test func periodFormatting_customAllowedUnits() { #expect( Period.zero.formatted(.full.allowedUnits([.day, .hour, .minute, .second]).locale(enLocale)) - == "0 seconds" + == "0 seconds", ) #expect( Period(years: 1, months: 2, days: 3, hours: 4, minutes: 5, seconds: 6).formatted(.full.allowedUnits([.day, .hour, .minute, .second]).locale(enLocale)) - == "427 days, 4 hours, 5 minutes, 6 seconds" + == "427 days, 4 hours, 5 minutes, 6 seconds", ) } } @@ -51,11 +51,11 @@ extension FormattingTests { @Test func periodFormatting_esLocale() { #expect( Period.zero.formatted(.full.locale(esLocale)) - == "0 segundos" + == "0 segundos", ) #expect( Period(years: 1, months: 2, days: 3, hours: 4, minutes: 5, seconds: 6).formatted(.full.locale(esLocale)) - == "1 año, 2 meses, 3 días, 4 horas, 5 minutos y 6 segundos" + == "1 año, 2 meses, 3 días, 4 horas, 5 minutos y 6 segundos", ) } }