Duration
Undocumented
-
Undocumented
-
Convert duration to seconds
1.year.toSeconds #=> 31556952 (length of a gregorian year 365.2425 days) 1.month.toSeconds #=> 2629746 (1/12 of a gregorian year) 1.week.toSeconds #=> 604800 1.day.toSeconds #=> 86400 1.hour.toSeconds #=> 3600 1.minute.toSeconds #=> 60 1.second.toSeconds #=> 1
Declaration
Swift
public var toSeconds: Int
-
Declaration
Swift
public var description: String
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Undocumented
-
Convert duration to seconds in string form.
Declaration
Swift
var to_s: String
-
Convert duration to seconds.
1.year.to_i #=> 31556952 (length of a gregorian year 365.2425 days) 1.month.to_i #=> 2629746 ( 1/12 of a gregorian year) 1.week.to_i #=> 604800 1.day.to_i #=> 86400 1.hour.to_i #=> 3600 1.minute.to_i #=> 60 1.second.to_i #=> 1
Declaration
Swift
var to_i: Int
-
Undocumented
-
Convert current struct to a
DateComponents
object, all the components of duration will be assigned toDateComponents
object.Declaration
Swift
func to_dateComponents(before: Bool = false) -> DateComponents
Parameters
before
A bool value indicates the sign of date components
Return Value
A
DateComponents
object containing all the date info
-
Returns a Boolean value indicating whether the value of the first argument is less than that of the second argument.
This function is the only requirement of the
Comparable
protocol. The remainder of the relational operator functions are implemented by the standard library for any type that conforms toComparable
.Declaration
Swift
public static func <(lhs: Duration, rhs: Duration) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
a
andb
,a == b
implies thata != b
isfalse
.Declaration
Swift
public static func ==(lhs: Duration, rhs: Duration) -> Bool
Parameters
lhs
A value to compare.
rhs
Another value to compare.
-
Returns a new
Duration
with the sum of the twoDuration
1.year + 1.year #=> 2.years 2.years + 3.years #=> 5.years 2.years + 1.year + 1.month #=> 3.years + 1.month
Declaration
Swift
static func +(lhs: Duration, rhs: Duration) -> Duration
Parameters
lhs
A duration
rhs
Another duration
Return Value
A new duration
-
Returns a new
Duration
with the subtraction from the left hand sideDuration
with the right hand side.1.year - 1.year #=> 0.year 2.year - 1.year #=> 1.year 2.years - 3.years #=> (-1).year 2.years - 1.year - 1.month #=> 1.year - 1.month
Declaration
Swift
static func -(lhs: Duration, rhs: Duration) -> Duration
Parameters
lhs
A duration
rhs
Another duration
Return Value
A new duration
-
Retrieve the years component from duration instance.
Declaration
Swift
var years: Int
-
Retrieve the months component from duration instance.
Declaration
Swift
var months: Int
-
Retrieve the weeks component from duration instance.
Declaration
Swift
var weeks: Int
-
Retrieve the days component from duration instance.
Declaration
Swift
var days: Int
-
Retrieve the hours component from duration instance.
Declaration
Swift
var hours: Int
-
Retrieve the minutes component from duration instance.
Declaration
Swift
var minutes: Int
-
Retrieve the seconds component from duration instance.
Declaration
Swift
var seconds: Int