Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 9 additions & 7 deletions .github/workflows/VerifyChanges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ on:
push:
branches: ["main"]

env:
XCODE_VERSION: 26.0.1

jobs:
lint:
name: Lint
runs-on: macos-26
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode 26.0.0
run: |
sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Select Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app
- name: Lint
run: |
Scripts/lint
Expand Down Expand Up @@ -55,8 +57,8 @@ jobs:
XCODE_TEST_PRODUCTS_PATH: .build/DevFoundation.xctestproducts

steps:
- name: Select Xcode 26.0.0
run: sudo xcode-select -s /Applications/Xcode_26.0.0.app
- name: Select Xcode ${{ env.XCODE_VERSION }}
run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app

- name: Checkout
uses: actions/checkout@v4
Expand All @@ -73,12 +75,12 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ${{ env.XCODE_TEST_PRODUCTS_PATH }}
key: cache-xctestproducts-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
key: cache-xctestproducts-${{ github.workflow }}-${{ matrix.platform }}-${{ env.XCODE_VERSION }}-${{ github.sha }}

- uses: irgaly/xcode-cache@v1
if: steps.cache-xctestproducts-restore.outputs.cache-hit != 'true'
with:
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-${{ github.sha }}
key: xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-${{ env.XCODE_VERSION }}-${{ github.sha }}
restore-keys: |
xcode-cache-deriveddata-${{ github.workflow }}-${{ matrix.platform }}-
xcode-cache-deriveddata-
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# DevFoundation Changelog


## 1.3.0: TBD
## 1.3.0: October 8, 2025

- We’ve added a computed property spelled `timeInterval` to `Duration`, which returns the
duration as a `TimeInterval`.
- We’ve updated the internal implementation of `ContextualEventBusObserver` to use an actor
instead of a class with a dispatch queue. This should have no impact on consumers.

Expand Down
18 changes: 18 additions & 0 deletions Sources/DevFoundation/Extensions/Duration+TimeInterval.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Duration+TimeInterval.swift
// DevFoundation
//
// Created by Prachi Gauriar on 10/8/25.
//

import Foundation

extension Duration {
/// A `TimeInterval` representation of the duration.
///
/// This computed property converts the duration to a `TimeInterval` by dividing the duration by one second. This is
/// useful for interoperability with APIs that expect `TimeInterval` values, such as Foundation’s `Date` APIs.
public var timeInterval: TimeInterval {
TimeInterval(self / .seconds(1.0))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Duration+TimeIntervalTests.swift
// DevFoundation
//
// Created by Prachi Gauriar on 10/8/25.
//

import DevFoundation
import DevTesting
import Foundation
import RealModule
import Testing

struct Duration_TimeIntervalTests: RandomValueGenerating {
var randomNumberGenerator = makeRandomNumberGenerator()


@Test
mutating func timeIntervalReturnsCorrectValue() {
#expect(Duration.seconds(0).timeInterval == 0)
#expect(Duration.milliseconds(-500).timeInterval == -0.5)
#expect(Duration.milliseconds(1375).timeInterval == 1.375)

for _ in 0 ..< 100 {
let originalTimeInterval = random(TimeInterval.self, in: -100_000 ... 100_000)
#expect(
Duration
.seconds(originalTimeInterval).timeInterval
.isApproximatelyEqual(to: originalTimeInterval, absoluteTolerance: 0.001)
)
}
}
}