Duration
A representation of high precision time.
Declaration
@frozen struct DurationOverview
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 secondsDuration 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.
Topics
Creating a duration
init(secondsComponent:attosecondsComponent:)seconds(_:)seconds(_:)milliseconds(_:)milliseconds(_:)microseconds(_:)microseconds(_:)