{"id":13536861,"url":"https://github.com/softartdev/Kronos-Multiplatform","last_synced_at":"2025-04-02T03:31:14.045Z","repository":{"id":165508626,"uuid":"618633459","full_name":"softartdev/Kronos-Multiplatform","owner":"softartdev","description":"Kotlin Multiplatform SNTP library","archived":false,"fork":false,"pushed_at":"2025-02-15T19:39:06.000Z","size":240,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T20:28:44.496Z","etag":null,"topics":["android","datetime","ios","java","kotlin","kotlin-coroutines","kotlin-multiplatform","kotlin-multiplatform-mobile","kotlin-native","kronos","ntp","sntp","time"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softartdev.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-24T22:57:58.000Z","updated_at":"2024-12-29T11:47:53.000Z","dependencies_parsed_at":"2025-02-15T20:34:41.113Z","dependency_job_id":null,"html_url":"https://github.com/softartdev/Kronos-Multiplatform","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":"JetBrains/compose-multiplatform-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softartdev%2FKronos-Multiplatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softartdev%2FKronos-Multiplatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softartdev%2FKronos-Multiplatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softartdev%2FKronos-Multiplatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softartdev","download_url":"https://codeload.github.com/softartdev/Kronos-Multiplatform/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246751100,"owners_count":20827834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","datetime","ios","java","kotlin","kotlin-coroutines","kotlin-multiplatform","kotlin-multiplatform-mobile","kotlin-native","kronos","ntp","sntp","time"],"created_at":"2024-08-01T09:00:50.720Z","updated_at":"2025-04-02T03:31:13.344Z","avatar_url":"https://github.com/softartdev.png","language":"Swift","funding_links":[],"categories":["Libraries"],"sub_categories":["Utility","⏰ Date-Time"],"readme":"# Kronos Multiplatform Library\n\n![Maven Central](https://img.shields.io/maven-central/v/io.github.softartdev/kronos)\n[![Build \u0026 Publish CI/CD](https://github.com/softartdev/Kronos-Multiplatform/actions/workflows/build_publish.yml/badge.svg)](https://github.com/softartdev/Kronos-Multiplatform/actions/workflows/build_publish.yml)\n\nKotlin Multiplatform library for network time synchronization. It is an extension for the [kotlinx-datetime](https://github.com/Kotlin/kotlinx-datetime) library and supports the following platforms:\n- Android\n- iOS\n- Desktop JVM (MacOS, Linux, Windows)\n## Usage\n### kotlinx-datetime Extension\nThe library [extends the main `Clock` interface](https://github.com/softartdev/Kronos-Multiplatform/blob/main/kronos/src/commonMain/kotlin/com/softartdev/kronos/ClockExt.kt) of the kotlinx-library. You can use the [Clock.Network](https://github.com/softartdev/Kronos-Multiplatform/blob/main/kronos/src/commonMain/kotlin/com/softartdev/kronos/NetworkClock.kt) class to retrieve the current network time, similar to using the built-in [Clock.System](https://github.com/Kotlin/kotlinx-datetime/blob/master/core/common/src/Clock.kt) instance.\n```kotlin\nval networkTime: Instant = Clock.Network.now()\nval systemTime: Instant = Clock.System.now()\nval diff: Duration = networkTime - systemTime\n```\n### Synchronization\nWhen running the application, it's necessary to synchronize the time with the network using the platform-specific code:\n- Android:\n```kotlin\nclass App : Application() {\n    override fun onCreate() {\n        super.onCreate()\n        Clock.Network.sync(applicationContext)\n    }\n}\n```\n- iOS:\n```swift\n@main\nstruct iosApp: App {\n    init() {\n        Clock.Network.sync()\n    }\n    var body: some Scene { ... }\n}\n```\n- Desktop JVM:\n```kotlin\nfun main() {\n    Clock.Network.sync()\n    ...\n}\n```\n### Installation\nThe latest release is available on [Maven Central](https://repo1.maven.org/maven2/io/github/softartdev/kronos/).\n1. Add the Maven Central repository if it is not already included:\n```kotlin\nrepositories {\n    mavenCentral()\n}\n```\n2. In multiplatform projects, add the following dependency to the `commonMain` source set dependencies:\n```kotlin\ncommonMain {\n    dependencies {\n        implementation(\"io.github.softartdev:kronos:$latestVersion\")\n    }\n}\n```\n## Implementation\nThe main common interface is implemented using the following:\n- [lyft/Kronos](https://github.com/lyft/Kronos-Android) for Java \u0026 Android\n- [MobileNativeFoundation/Kronos](https://github.com/MobileNativeFoundation/Kronos) for iOS\n\nThe project is built and tested using the following:\n- [Swift Klib Gradle Plugin](https://github.com/ttypic/swift-klib-plugin) for including Swift source files in KMM shared module\n- [Compose Multiplatform, by JetBrains](https://github.com/JetBrains/compose-jb) for UI samples\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftartdev%2FKronos-Multiplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftartdev%2FKronos-Multiplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftartdev%2FKronos-Multiplatform/lists"}