Swiftpack.co -  Package - randymarsh77/time
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A small utility to handle mach_absolute_time and timestamps.
.package(url: "https://github.com/randymarsh77/time.git", from: "2.0.1")


A small utility to handle timestamps and intervals.

license GitHub release SPM Build codecov.io codebeat badge


Create some time

let now = Time.Now

Get the system timestamp value. This is the mach_absolute_time on macOS and the result of clock_gettime using CLOCK_MONOTONIC_RAW, in nano seconds.

let ts = now.systemTimeStamp

Create some time with a system time stamp value

_ = Time.FromSystemTimeStamp(ts)

Add a second

let aSecondFromNow = now + Time.FromInterval(1, unit: .Seconds)

Subtract some micros

_ = aSecondFromNow - Time.FromInterval(1234, unit: .Microseconds)


_ = aSecondFromNow == now
_ = aSecondFromNow != now

Make a second

aSecond = aSecondFromNow - now

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco