From ebce2c4b839c0b2f8be78bc31c1ce12c45a0164c Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 13 Oct 2018 03:37:40 +0200 Subject: Major refactoring of the multi-platform components. Dependencies upgrade. A lot of code style fixes. --- .../main/kotlin/pl/treksoft/kvision/types/Date.kt | 28 +++++++++++++ .../main/kotlin/pl/treksoft/kvision/types/KDate.kt | 49 ---------------------- 2 files changed, 28 insertions(+), 49 deletions(-) create mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/Date.kt delete mode 100644 kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt (limited to 'kvision-modules/kvision-common/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/Date.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/Date.kt new file mode 100644 index 00000000..86a72b33 --- /dev/null +++ b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/Date.kt @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.types + +expect class Date + +expect fun String.toDateF(format: String = "YYYY-MM-DD HH:mm:ss"): Date + +expect fun Date.toStringF(format: String = "YYYY-MM-DD HH:mm:ss"): String diff --git a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt b/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt deleted file mode 100644 index 0cb1a1f1..00000000 --- a/kvision-modules/kvision-common/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017-present Robert Jaros - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package pl.treksoft.kvision.types - -import kotlinx.serialization.Serializable - -expect val KDATE_FORMAT: String - -/** - * A serializable wrapper for a multiplatform Date type. - */ -@Serializable -data class KDate(val time: Long) { - constructor() : this(now().time) - constructor(str: String) : this(str.toKDateF(KDATE_FORMAT).time) - - override fun toString(): String { - return this.toStringF(KDATE_FORMAT) - } - - companion object { - fun now() = nowDate() - } -} - -expect fun nowDate(): KDate - -expect fun String.toKDateF(format: String): KDate - -expect fun KDate.toStringF(format: String): String -- cgit