Skip to content

Commit

Permalink
chore: Add attoseconds accessor (#3)
Browse files Browse the repository at this point in the history
* Add attoseconds accessor.

* Add initializer.
  • Loading branch information
hassila committed Nov 28, 2022
1 parent 26f1193 commit ccdb50c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Sources/DateTime/InternalUTCClock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@ public struct InternalUTCClock {
internal init(_value: Swift.Duration) {
self._value = _value
}


public init(secondsComponent: Int64, attosecondsComponent: Int64) {
self._value = Swift.Duration(secondsComponent: secondsComponent, attosecondsComponent: attosecondsComponent)
}

@available(*, deprecated, renamed: "seconds")
public func secondsSinceEpoch() -> Int64 {
return self._value.components.seconds
}

public func seconds() -> Int64 {
return self._value.components.seconds
}

public func attoseconds() -> Int64 {
return self._value.components.attoseconds
}
}

public init() {}
Expand Down

0 comments on commit ccdb50c

Please sign in to comment.