SyncTimeUtils.kt 16 lignes · 578 octets
package fr.ebii.card2vcf.sync

/** ISO-8601 UTC → epoch ms, tolérant aux valeurs absentes/invalides (miroir horodatages serveur `mis_a_jour_le`). */
internal fun parseIsoToEpochMs(iso: String?): Long =
    if (iso == null) {
        0L
    } else {
        try {
            java.time.Instant.parse(iso).toEpochMilli()
        } catch (_: Exception) {
            0L
        }
    }

/** epoch ms → ISO-8601 UTC, pour les payloads poussés au serveur (`debut`/`fin`). */
internal fun epochMsToIso(epochMs: Long): String = java.time.Instant.ofEpochMilli(epochMs).toString()