Kronos is an NTP client library written in Swift. It supports sub-seconds precision and provides a stable monotonic clock that won’t be affected by changes in the clock.
Example app
This is an example app that displays the monotonic Clock.now
on the left and the system clock (initially out of date) on the right.
Usage
Calling Clock.sync
will fire a bunch of NTP requests to up to 5 of the servers on the given NTP pool (default is time.apple.com
). As soon as we get the first response, the given closure is called but the Clock
will keep trying to get a more accurate response.