Skip to content

sentryco/NetTime

Repository files navigation

Tests codebeat badge

๐Ÿ•‘ NetTime

Network-time-synchronization in swift

Features

  • Network Time Protocol (NTP) support for accurate time synchronization.
  • Easy to use API for fetching and using network time.
  • Caching of server time for quick access.
  • Compatible with iOS and macOS.

Requirements

  • iOS 17 and later
  • macOS 14 and later

Installation

To add the NetTime package to your Swift project, add the following line to the dependencies value of your Package.swift.

.package(url: "https://github.com/sentryco/NetTime", branch: "main")

Then include "NetTime" in the dependencies value of any Target in which you want to use NetTime.

Usage

Here's an example of how to use NetTime:

import NetTime

Date.updateTime { // Call when app launches etc
    print("โ˜€๏ธ Current Date: \(Date().formatted())")
    print("โ˜Ž๏ธ Server time: \(Date.serverTime.formatted())")
}
Date.serverTime // Returns the cached server date

Competitors:

There are several libraries available for network time synchronization in Swift. Here are a few:

  1. TrueTime.swift: An NTP client for Swift. This library allows you to get the "true" network time, and not rely on the device's system clock.

  2. Kronos: Another NTP based time synchronization library developed by Lyft.

  3. NetClock: A simple NTP client to get internet time in Swift.

  4. SwiftNTP: A simple Network Time Protocol client written in Swift.

Tip

Remember to check the documentation and the community around these libraries to ensure they fit your needs and are actively maintained.

Contributing

Contributions are welcome! Please read our contributing guidelines for details.

License

NetTime is released under the MIT License. See LICENSE for details.

About

๐Ÿ•‘ Network-time-synchronization in swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages