<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TimeDataSource",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14TimeDataSourceV"
  },
  "title" : "TimeDataSource"
}
-->

# TimeDataSource

A source of time related data.

```
struct TimeDataSource<Value>
```

## Overview

Instances of this type provide [`Text`](/documentation/SwiftUI/Text) with live and automatically updating
values in Widgets, Live Activities, watchOS Complications, and of course
regular apps.

## Topics

### Type Properties

[`static var currentDate: TimeDataSource<Date>`](/documentation/SwiftUI/TimeDataSource/currentDate)

A time data source that produces `Date.now`.

### Type Methods

[`static func dateRange(endingAt: Date) -> TimeDataSource<Range<Date>>`](/documentation/SwiftUI/TimeDataSource/dateRange(endingAt:))

A time data source that produces `min(date, Date.now)..<date`.

[`static func dateRange(startingAt: Date) -> TimeDataSource<Range<Date>>`](/documentation/SwiftUI/TimeDataSource/dateRange(startingAt:))

A time data source that produces `date..<max(date, Date.now)`.

[`static func durationOffset(to: Date) -> TimeDataSource<Duration>`](/documentation/SwiftUI/TimeDataSource/durationOffset(to:))

A time data source that produces the offset between `Date.now` and the given
`date` as a `Duration`.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)