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
TimeIntervalrepresenting the given number of seconds.Declaration
Swift
var seconds: TimeInterval -
minutesDefault implementationA
TimeIntervalrepresenting the given number of minutes.Default Implementation
The default implementation of
minutesreturnsseconds * 60.Declaration
Swift
var minutes: TimeInterval -
hoursDefault implementationA
TimeIntervalrepresenting the given number of hours.Default Implementation
The default implementation of
hoursreturnsminutes * 60.Declaration
Swift
var hours: TimeInterval -
daysDefault implementationA
TimeIntervalrepresenting the given number of days.Default Implementation
The default implementation of
daysreturnshours * 24.Declaration
Swift
var days: TimeInterval -
weeksDefault implementationReturns an
TimeIntervalrepresenting the given number of weeks.Default Implementation
The default implementation of
weeksreturnsdays * 7.Declaration
Swift
var weeks: TimeInterval
-
secondExtension methodAn alias for
secondsdesigned for correct grammar where single units are used, eg.1.second.Declaration
Swift
public var second: TimeInterval -
minuteExtension methodAn alias for
minutesdesigned for correct grammar where single units are used, eg.1.minute.Declaration
Swift
public var minute: TimeInterval -
hourExtension methodAn alias for
hoursdesigned for correct grammar where single units are used, eg.1.hour.Declaration
Swift
public var hour: TimeInterval -
dayExtension methodAn alias for
daysdesigned for correct grammar where single units are used, eg.1.day.Declaration
Swift
public var day: TimeInterval -
weekExtension methodAn alias for
weeksdesigned for correct grammar where single units are used, eg.1.week.Declaration
Swift
public var week: TimeInterval
View on GitHub
TimeIntervalLiterals Protocol Reference