Apache License 2.0

项目介绍

MobileNativeFoundation/Kronos 是一个托管在 GitHub 上的开源项目,主要使用 Swift 编写,采用 Apache License 2.0 许可证,目前获得 702 个 Star、96 次 Fork。

仓库全名
MobileNativeFoundation/Kronos
开源许可证
Apache License 2.0
Star 数
702
Fork 数
96
未关闭 Issue
12

README 摘要

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 Sync clock using a pool of NTP servers Calling Clock.sync will fire a bunch of NTP requests to up…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Kronos 用什么语言开发?

主要使用 Swift 编写,采用 Apache License 2.0 许可证,目前有 702 个 Star。

Kronos 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 Kronos 的源码?

可以直接克隆仓库:git clone https://github.com/MobileNativeFoundation/Kronos.git,默认分支为 main;安装与运行步骤见仓库 README。

Kronos 最近还在维护吗?

仓库最近一次更新为 2025年6月13日,当前有 12 个未关闭 Issue;Star 数为 702,可作为社区活跃度的参考。

关于

Elegant NTP date library in Swift

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
914
价值分
451
活跃状态
活跃

语言占比

Makefile
Ruby
Starlark
Swift

README

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.

ascii-clock

Usage

Sync clock using a pool of NTP servers

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.

Clock.sync { date, offset in
    // This is the first sync (note that this is the fastest but not the
    // most accurate run
    print(date)
}

Get an NTP sync’ed date

Clock.now is a monotonic NSDate that won’t be affected by clock changes.

NSTimer.scheduledTimerWithTimeInterval(1.0, target: self,
                                       selector: #selector(Example.tick),
                                       userInfo: nil, repeats: true)

@objc func tick() {
    print(Clock.now) // Note that this clock will get more accurate as
                     // more NTP servers respond.
}

Installation

CocoaPods

Add Kronos to your Podfile:

pod 'Kronos'

Swift Package Manager

Add Kronos to your Package.swift:

.package(name: "Kronos", url: "https://github.com/MobileNativeFoundation/Kronos.git", .upToNextMajor(from: "TAG")),

Bazel

Add Kronos to your WORKSPACE:

http_archive(
    name = "Kronos",
    sha256 = "",
    strip_prefix = "Kronos-TAG/",
    url = "https://github.com/MobileNativeFoundation/Kronos/archive/TAG.tar.gz",
)

Then depend on @Kronos//:Kronos

Android

Check out Kronos for Android

评论

暂无评论