TimeIntervalLiterals
public protocol TimeIntervalLiterals
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
.
-
A
TimeInterval
representing the given number of seconds.Declaration
Swift
var seconds: TimeInterval
-
minutes
Default implementationA
TimeInterval
representing the given number of minutes.Default Implementation
The default implementation of
minutes
returnsseconds * 60
.Declaration
Swift
var minutes: TimeInterval
-
hours
Default implementationA
TimeInterval
representing the given number of hours.Default Implementation
The default implementation of
hours
returnsminutes * 60
.Declaration
Swift
var hours: TimeInterval
-
days
Default implementationA
TimeInterval
representing the given number of days.Default Implementation
The default implementation of
days
returnshours * 24
.Declaration
Swift
var days: TimeInterval
-
weeks
Default implementationReturns an
TimeInterval
representing the given number of weeks.Default Implementation
The default implementation of
weeks
returnsdays * 7
.Declaration
Swift
var weeks: TimeInterval
-
second
Extension methodAn alias for
seconds
designed for correct grammar where single units are used, eg.1.second
.Declaration
Swift
public var second: TimeInterval
-
minute
Extension methodAn alias for
minutes
designed for correct grammar where single units are used, eg.1.minute
.Declaration
Swift
public var minute: TimeInterval
-
hour
Extension methodAn alias for
hours
designed for correct grammar where single units are used, eg.1.hour
.Declaration
Swift
public var hour: TimeInterval
-
day
Extension methodAn alias for
days
designed for correct grammar where single units are used, eg.1.day
.Declaration
Swift
public var day: TimeInterval
-
week
Extension methodAn alias for
weeks
designed for correct grammar where single units are used, eg.1.week
.Declaration
Swift
public var week: TimeInterval