A representation of high precision time.
- iOS 9999+
- macOS 9999+
- tvOS 9999+
- watchOS 9999+
@frozen struct Duration
Duration represents an elapsed time value with high precision in an integral form. It may be used for measurements of varying clock sources. In those cases it represents the elapsed time measured by that clock. Calculations using
Duration may span from a negative value to a positive value and have a suitable range to at least cover attosecond scale for both small elapsed durations like sub-second precision to durations that span centuries.
Typical construction of
Duration values should be created via the static methods for specific time values.
var d: Duration = .seconds(3) d += .milliseconds(33) print(d) // 3.033 seconds
Duration itself does not ferry any additional information other than the temporal measurement component; specifically leap seconds should be represented as an additional accessor since that is specific only to certain clock implementations.