StructureSwift

    Duration

    A representation of high precision time.

    • iOS 16.0+
    • macOS 13.0+
    • tvOS 16.0+
    • watchOS 9.0+
    @frozen struct Duration

    Overview

    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.

    Members

    Initializers

    Type Properties

    Instance Properties

    Type Methods

    Instance Methods

    Type Operators