From f3c4747053804c2b3124fba441a7290ca94723d5 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 23 May 2019 20:06:29 +0800 Subject: [PATCH] update defaults in KronTime --- .../krontab/parts/KronTime.kt | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/parts/KronTime.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/parts/KronTime.kt index 2017efa..eb12210 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/parts/KronTime.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/parts/KronTime.kt @@ -68,18 +68,18 @@ internal fun KronTimes( hoursParts ?.flatMap { hours -> weekDaysParts ?.map { weekDay -> KronTime(millis, seconds, minutes, hours, weekDay) - } ?: listOf(KronTime(millis, seconds, minutes, hours, null)) - } ?: listOf(KronTime(millis, seconds, minutes, null, null)) - } ?: listOf(KronTime(millis, seconds, null, null, null)) - } ?: listOf(KronTime(millis, null, null, null, null)) - } ?: listOf(KronTime(null, null, null, null, null)) + } ?: listOf(KronTime(millis, seconds, minutes, hours)) + } ?: listOf(KronTime(millis, seconds, minutes)) + } ?: listOf(KronTime(millis, seconds)) + } ?: listOf(KronTime(milliseconds = millis)) + } ?: listOf(KronTime()) } internal fun KronTime( - milliseconds: Milliseconds + fullMillis: Milliseconds ): KronTime { - val millis = (milliseconds % millisCount).toShort() - var currentDivided: Double = floor(milliseconds.toDouble() / millisCount) + val millis = (fullMillis % millisCount).toShort() + var currentDivided: Double = floor(fullMillis.toDouble() / millisCount) val seconds: Byte = (currentDivided % secondsCount).toByte() currentDivided = floor(currentDivided / secondsCount) @@ -102,9 +102,9 @@ internal fun KronTime( } internal data class KronTime( - val milliseconds: Milliseconds?, - val seconds: Seconds?, - val minutes: Minutes?, - val hours: Hours?, - val weekDays: WeekDays? + val milliseconds: Milliseconds? = null, + val seconds: Seconds? = null, + val minutes: Minutes? = null, + val hours: Hours? = null, + val weekDays: WeekDays? = null )