Store every date in the database as an Instant

This commit is contained in:
AntsyLich
2026-10-10 17:37:43 +06:00
parent 8972882a34
commit 44c1e1915d
68 changed files with 599 additions and 284 deletions
@@ -0,0 +1,14 @@
package mihon.core.common.extensions
import kotlin.time.Instant
/**
* Reads epoch milliseconds from a format that writes 0 for a time it doesn't know, such as the source API, a tracker
* or a backup.
*/
fun Long.toInstantOrNull(): Instant? = takeIf { it != 0L }?.let(Instant::fromEpochMilliseconds)
/**
* Writes epoch milliseconds to a format that takes 0 for a time it doesn't know.
*/
fun Instant?.toEpochMillisOrZero(): Long = this?.toEpochMilliseconds() ?: 0L