Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.38 KB

README.md

File metadata and controls

55 lines (38 loc) · 1.38 KB

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