-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce korlibs-time module (#2045)
- Loading branch information
Showing
102 changed files
with
58 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import korlibs.* | ||
|
||
description = "Korlibs Time - Former Klock" | ||
|
||
project.extensions.extraProperties.properties.apply { | ||
applyProjectProperties( | ||
"https://raw.githubusercontent.com/korlibs/korge/main/korlibs-time", | ||
"Public Domain", | ||
"https://raw.githubusercontent.com/korlibs/korge/main/korlibs-time/LICENSE" | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...-foundation/src/korlibs/time/DayOfWeek.kt → korlibs-time/src/korlibs/time/DayOfWeek.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...-foundation/src/korlibs/time/Frequency.kt → korlibs-time/src/korlibs/time/Frequency.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package korlibs.time | ||
|
||
import korlibs.math.* | ||
import korlibs.time.internal.* | ||
import kotlin.jvm.* | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 3 additions & 15 deletions
18
korge-foundation/src/korlibs/time/Month.kt → korlibs-time/src/korlibs/time/Month.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...ion/src/korlibs/time/PatternDateFormat.kt → ...ime/src/korlibs/time/PatternDateFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ion/src/korlibs/time/PatternTimeFormat.kt → ...ime/src/korlibs/time/PatternTimeFormat.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions
6
...oundation/src/korlibs/time/TimeSampler.kt → korlibs-time/src/korlibs/time/TimeSampler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
...e-foundation/src/korlibs/time/TimeSpan.kt → korlibs-time/src/korlibs/time/TimeSpan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package korlibs.time.internal | ||
|
||
import kotlin.math.* | ||
|
||
internal infix fun Int.umod(other: Int): Int { | ||
val rm = this % other | ||
val remainder = if (rm == -0) 0 else rm | ||
return when { | ||
remainder < 0 -> remainder + other | ||
else -> remainder | ||
} | ||
} | ||
internal infix fun Double.umod(other: Double): Double { | ||
val rm = this % other | ||
val remainder = if (rm == -0.0) 0.0 else rm | ||
return when { | ||
remainder < 0.0 -> remainder + other | ||
else -> remainder | ||
} | ||
} | ||
internal infix fun Int.div2(other: Int): Int = when { | ||
this < 0 || this % other == 0 -> this / other | ||
else -> (this / other) - 1 | ||
} | ||
|
||
internal fun Int.cycle(min: Int, max: Int): Int = ((this - min) umod (max - min + 1)) + min | ||
internal fun Int.cycleSteps(min: Int, max: Int): Int = (this - min) / (max - min + 1) | ||
internal fun Double.toInt2(): Int = if (this < 0.0) floor(this).toInt() else this.toInt() | ||
internal fun Double.toIntMod(mod: Int): Int = (this umod mod.toDouble()).toInt2() |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters