init(secondsComponent:attosecondsComponent:)
Construct a Duration by adding attoseconds to a seconds value.
Declaration
init(secondsComponent: Int64, attosecondsComponent: Int64)Parameters
- secondsComponent:
The seconds component portion of the
Durationvalue. - attosecondsComponent:
The attosecond component portion of the
Durationvalue.
Discussion
This is useful for when an external decomposed components of a Duration has been stored and needs to be reconstituted. Since the values are added no precondition is expressed for the attoseconds being limited to 1e18.
let d1 = Duration(
secondsComponent: 3,
attosecondsComponent: 123000000000000000)
print(d1) // 3.123 seconds
let d2 = Duration(
secondsComponent: 3,
attosecondsComponent: -123000000000000000)
print(d2) // 2.877 seconds
let d3 = Duration(
secondsComponent: -3,
attosecondsComponent: -123000000000000000)
print(d3) // -3.123 seconds