---
title: "init(secondsComponent:attosecondsComponent:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/duration/init(secondscomponent:attosecondscomponent:)"
---

# init(secondsComponent:attosecondsComponent:)

Construct a Duration by adding attoseconds to a seconds value.

## Declaration

```swift
init(secondsComponent: Int64, attosecondsComponent: Int64)
```

## Parameters

- `secondsComponent`: The seconds component portion of the Duration value.
- `attosecondsComponent`: The attosecond component portion of the Duration value.

## Discussion

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

## See Also

### Creating a duration

- [seconds(_:)](swift/duration/seconds(_:)-311cx.md)
- [seconds(_:)](swift/duration/seconds(_:)-5ifzr.md)
- [milliseconds(_:)](swift/duration/milliseconds(_:)-1w328.md)
- [milliseconds(_:)](swift/duration/milliseconds(_:)-7ledy.md)
- [microseconds(_:)](swift/duration/microseconds(_:)-1zzcc.md)
- [microseconds(_:)](swift/duration/microseconds(_:)-2majo.md)
