Skip to content

Commit 82ec848

Browse files
committed
refactor: update Kotlin time API usage and improve build configurations
1 parent 33a7428 commit 82ec848

File tree

30 files changed

+256
-166
lines changed

30 files changed

+256
-166
lines changed

.github/workflows/build_only.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build CI
1+
name: Kotlin Multiplatform CI
22

33
on:
44
push:
@@ -7,28 +7,30 @@ on:
77
tags-ignore:
88
- '**'
99
pull_request:
10-
branches: [ master ]
1110

1211
jobs:
1312
build_job:
14-
name: Build (Unit-tests)
13+
name: Build (Unit-tests & Android-Lint)
1514
runs-on: macos-latest
15+
continue-on-error: true
1616
steps:
17-
- uses: actions/checkout@v1
18-
- name: Cache gradle
19-
uses: actions/cache@v1
17+
- name: Check out
18+
uses: actions/checkout@v4
19+
- name: Gradle Wrapper Validation
20+
uses: gradle/wrapper-validation-action@v1
21+
- name: Set up JDK 17
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: 'oracle'
25+
java-version: 17
26+
- name: Setup Gradle
27+
uses: gradle/actions/setup-gradle@v4
2028
with:
21-
path: ~/.gradle/caches
22-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
23-
restore-keys: |
24-
${{ runner.os }}-gradle-
29+
cache-read-only: false
30+
cache-overwrite-existing: true
2531
- name: Decrypt large secret
2632
run: ./.github/scripts/decrypt_secret.sh
2733
env:
2834
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
29-
- name: Set up JDK 17
30-
uses: actions/setup-java@v1
31-
with:
32-
java-version: 17
3335
- name: Build
34-
run: ./gradlew build
36+
run: ./gradlew build

.github/workflows/build_publish.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ jobs:
1010
name: Build -> Unit-test -> Publish
1111
runs-on: macos-latest
1212
steps:
13-
- uses: actions/checkout@v1
14-
- name: Cache gradle
15-
uses: actions/cache@v1
13+
- uses: actions/checkout@v4
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v4
16+
with:
17+
distribution: 'oracle'
18+
java-version: 17
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
1621
with:
17-
path: ~/.gradle/caches
18-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
19-
restore-keys: |
20-
${{ runner.os }}-gradle-
22+
cache-read-only: false
23+
cache-overwrite-existing: true
2124
- name: Decrypt large secret
2225
run: ./.github/scripts/decrypt_secret.sh
2326
env:
2427
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
25-
- name: Set up JDK 17
26-
uses: actions/setup-java@v1
27-
with:
28-
java-version: 17
2928
- name: Build
3029
run: ./gradlew build
3130
- name: Publish
31+
continue-on-error: true
3232
run: ./gradlew publishAllPublicationsToSonatypeRepository --max-workers 1 closeAndReleaseRepository

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ xcuserdata/
1313
Pods/
1414
*.jks
1515
*yarn.lock
16+
/.kotlin

README.MD

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
![Maven Central](https://img.shields.io/maven-central/v/io.github.softartdev/kronos)
44
[![Build & 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)
55

6-
Kotlin 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:
6+
Kotlin Multiplatform library for network time synchronization. It extends the [`kotlin.time`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.time/) API and supports the following platforms:
77
- Android
88
- iOS
99
- Desktop JVM (MacOS, Linux, Windows)
1010
## Usage
11-
### kotlinx-datetime Extension
12-
The 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.
11+
### `kotlin.time` Extension
12+
The library [extends the main `Clock` interface](https://github.com/softartdev/Kronos-Multiplatform/blob/main/kronos/src/commonMain/kotlin/com/softartdev/kronos/ClockExt.kt) from the standard 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/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/time/Clock.kt#L60) instance.
1313
```kotlin
14-
val networkTime: Instant = Clock.Network.now()
15-
val systemTime: Instant = Clock.System.now()
16-
val diff: Duration = networkTime - systemTime
14+
val networkTime: Instant = Clock.Network.now() // 2025-06-30T13:42:43.712Z
15+
val systemTime: Instant = Clock.System.now() // 2025-06-30T13:42:43.566455Z
16+
val diff: Duration = networkTime - systemTime // 145.545ms
1717
```
1818
### Synchronization
1919
When running the application, it's necessary to synchronize the time with the network using the platform-specific code:

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
alias(libs.plugins.multiplatform).apply(false)
3+
alias(libs.plugins.compose.compiler).apply(false)
34
alias(libs.plugins.compose).apply(false)
45
alias(libs.plugins.cocoapods).apply(false)
56
alias(libs.plugins.android.application).apply(false)

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ org.gradle.caching=true
77

88
#Kotlin
99
kotlin.code.style=official
10+
kotlin.experimental.tryK2=true
1011

1112
#MPP
1213
kotlin.mpp.enableCInteropCommonization=true
1314
kotlin.mpp.androidSourceSetLayoutVersion=2
15+
kotlin.mpp.applyDefaultHierarchyTemplate=false
1416

1517
#Compose
1618
org.jetbrains.compose.experimental.uikit.enabled=true
@@ -20,7 +22,7 @@ kotlin.native.cacheKind=none
2022
android.useAndroidX=true
2123
android.nonTransitiveRClass=true
2224
android.nonFinalResIds=true
23-
android.defaults.buildfeatures.buildconfig=true
25+
android.buildFeatures.buildConfig=true
2426

2527
#gradle-nexus-staging-plugin
2628
gnsp.disableApplyOnlyOnRootProjectEnforcement=true

gradle/libs.versions.toml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
[versions]
2-
kronos = "0.0.1"
2+
kronos = "0.0.2"
3+
compileSdk = "36"
4+
targetSdk = "36"
5+
minSdk = "21"
36
lyft-kronos = "0.0.1-alpha11"
4-
kotlin = "1.8.20"
5-
agp = "8.0.1"
6-
compose = "1.4.0"
7-
androidx-appcompat = "1.6.1"
8-
androidx-activityCompose = "1.7.0"
9-
androidx-test = "1.5.0"
10-
compose-uitooling = "1.4.0"
11-
napier = "2.6.1"
12-
kotlinx-coroutines = "1.6.4"
13-
kotlinx-datetime = "0.4.0"
14-
swift-klib = "0.2.1"
7+
kotlin = "2.2.0"
8+
jdk = "17"
9+
agp = "8.11.0"
10+
compose = "1.8.2"
11+
androidx-appcompat = "1.7.1"
12+
androidx-activityCompose = "1.10.1"
13+
androidx-test = "1.6.1"
14+
compose-uitooling = "1.8.3"
15+
napier = "2.7.1"
16+
kotlinx-coroutines = "1.10.2"
17+
swift-klib = "0.6.4"
1518

1619
[libraries]
1720
kronos = { module = "io.github.softartdev:kronos", version.ref = "kronos" }
@@ -25,11 +28,11 @@ napier = { module = "io.github.aakira:napier", version.ref = "napier" }
2528
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
2629
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
2730
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
28-
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
2931

3032
[plugins]
3133
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
3234
cocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
35+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
3336
compose = { id = "org.jetbrains.compose", version.ref = "compose" }
3437
android-application = { id = "com.android.application", version.ref = "agp" }
3538
android-library = { id = "com.android.library", version.ref = "agp" }
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#Wed May 03 21:26:25 GET 2023
1+
#Fri Jun 27 19:10:37 GET 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip
5+
networkTimeout=10000
6+
validateDistributionUrl=true
57
zipStoreBase=GRADLE_USER_HOME
68
zipStorePath=wrapper/dists

iosApp/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ EXTERNAL SOURCES:
99
:path: "../sampleApp"
1010

1111
SPEC CHECKSUMS:
12-
sampleApp: edaddecea9407fd3435157244bdbed90f2dffe7b
12+
sampleApp: 74ffcffb09857e525c843f48fcd5511e65e94800
1313

1414
PODFILE CHECKSUM: 31aecb1c889393f7cb5f9aac6f63f896eb049a8e
1515

16-
COCOAPODS: 1.11.3
16+
COCOAPODS: 1.12.1

iosApp/iosApp.xcodeproj/project.pbxproj

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
/* Begin PBXFileReference section */
1717
05E67C72B2BDBC81379103CB /* Pods-iosApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.release.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.release.xcconfig"; sourceTree = "<group>"; };
1818
73FFDDCA9C728FEE3DFEF2F4 /* Pods-iosApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iosApp.debug.xcconfig"; path = "Target Support Files/Pods-iosApp/Pods-iosApp.debug.xcconfig"; sourceTree = "<group>"; };
19-
A93A953729CC810C00F8E227 /* Kronos Multiplatform.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Kronos Multiplatform.app"; sourceTree = BUILT_PRODUCTS_DIR; };
19+
751C49B92CF2A16F00D81888 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
20+
A93A953729CC810C00F8E227 /* Kronos Multiplatform.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Kronos Multiplatform.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2021
A93A953A29CC810C00F8E227 /* iosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iosApp.swift; sourceTree = "<group>"; };
2122
A93A953E29CC810D00F8E227 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2223
A93A954129CC810D00F8E227 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
@@ -65,6 +66,7 @@
6566
A93A953929CC810C00F8E227 /* iosApp */ = {
6667
isa = PBXGroup;
6768
children = (
69+
751C49B92CF2A16F00D81888 /* Info.plist */,
6870
A93A953A29CC810C00F8E227 /* iosApp.swift */,
6971
A93A953E29CC810D00F8E227 /* Assets.xcassets */,
7072
A93A954029CC810D00F8E227 /* Preview Content */,
@@ -99,6 +101,7 @@
99101
A93A953329CC810C00F8E227 /* Sources */,
100102
A93A953429CC810C00F8E227 /* Frameworks */,
101103
A93A953529CC810C00F8E227 /* Resources */,
104+
FC29032C0717E1CCFA494848 /* [CP] Copy Pods Resources */,
102105
);
103106
buildRules = (
104107
);
@@ -177,6 +180,23 @@
177180
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
178181
showEnvVarsInLog = 0;
179182
};
183+
FC29032C0717E1CCFA494848 /* [CP] Copy Pods Resources */ = {
184+
isa = PBXShellScriptBuildPhase;
185+
buildActionMask = 2147483647;
186+
files = (
187+
);
188+
inputFileListPaths = (
189+
"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-input-files.xcfilelist",
190+
);
191+
name = "[CP] Copy Pods Resources";
192+
outputFileListPaths = (
193+
"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources-${CONFIGURATION}-output-files.xcfilelist",
194+
);
195+
runOnlyForDeploymentPostprocessing = 0;
196+
shellPath = /bin/sh;
197+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iosApp/Pods-iosApp-resources.sh\"\n";
198+
showEnvVarsInLog = 0;
199+
};
180200
/* End PBXShellScriptBuildPhase section */
181201

182202
/* Begin PBXSourcesBuildPhase section */
@@ -316,6 +336,7 @@
316336
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
317337
ENABLE_PREVIEWS = YES;
318338
GENERATE_INFOPLIST_FILE = YES;
339+
INFOPLIST_FILE = iosApp/Info.plist;
319340
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
320341
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
321342
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
@@ -345,6 +366,7 @@
345366
DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\"";
346367
ENABLE_PREVIEWS = YES;
347368
GENERATE_INFOPLIST_FILE = YES;
369+
INFOPLIST_FILE = iosApp/Info.plist;
348370
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
349371
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
350372
INFOPLIST_KEY_UILaunchScreen_Generation = YES;

0 commit comments

Comments
 (0)