Protocols

The following protocols are available globally.

  • The TimeIntervalLiterals protocol is used to extend IntegerLiteralType and FloatLiteralType to allow for human-readable time notations such as:

    let sixtySeconds = 60.seconds
    let twoAndAHalfMinutes = 2.5.minutes
    let oneWeek = 7.days
    let anotherWeek = 1.week
    

    Default implementations of the minutes, hours, days, and weeks properties are supplied; implementors of the TimeIntervalLiterals protocol only need to supply an implementation for seconds.

    See more

    Declaration

    Swift

    public protocol TimeIntervalLiterals