Skip to content

A small utility to handle mach_absolute_time and timestamps.

License

Notifications You must be signed in to change notification settings

randymarsh77/time

Repository files navigation

Time

A small utility to handle timestamps and intervals.

license GitHub release SPM Build codecov.io codebeat badge

Usage

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)

Compare

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

Make a second

aSecond = aSecondFromNow - now

About

A small utility to handle mach_absolute_time and timestamps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages