aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-moment
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@users.noreply.github.com>2019-05-13 15:18:48 +0200
committerGitHub <noreply@github.com>2019-05-13 15:18:48 +0200
commit70e5bfa3a4057dc1610e823d4846c66d6ca91f6f (patch)
treeece1c4fd5303a3144f011b689ee63fd43561ac24 /kvision-modules/kvision-moment
parent5902d5c3f24e1cd6ca241e3b9589545480eea373 (diff)
parent7d815923590d951d23b6763b2efb771bd32111fe (diff)
downloadkvision-70e5bfa3a4057dc1610e823d4846c66d6ca91f6f.tar.gz
kvision-70e5bfa3a4057dc1610e823d4846c66d6ca91f6f.tar.bz2
kvision-70e5bfa3a4057dc1610e823d4846c66d6ca91f6f.zip
Merge pull request #44 from robert-cronin/master
Add momentjs wrapper to kvision-modules
Diffstat (limited to 'kvision-modules/kvision-moment')
-rw-r--r--kvision-modules/kvision-moment/build.gradle9
-rw-r--r--kvision-modules/kvision-moment/package.json.d/project.info3
-rw-r--r--kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt36
-rw-r--r--kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt91
4 files changed, 139 insertions, 0 deletions
diff --git a/kvision-modules/kvision-moment/build.gradle b/kvision-modules/kvision-moment/build.gradle
new file mode 100644
index 00000000..4325a38a
--- /dev/null
+++ b/kvision-modules/kvision-moment/build.gradle
@@ -0,0 +1,9 @@
+apply from: "../shared.gradle"
+
+kotlinFrontend {
+
+ npm {
+ dependency("moment", "2.24.0")
+ }
+
+}
diff --git a/kvision-modules/kvision-moment/package.json.d/project.info b/kvision-modules/kvision-moment/package.json.d/project.info
new file mode 100644
index 00000000..c68b247f
--- /dev/null
+++ b/kvision-modules/kvision-moment/package.json.d/project.info
@@ -0,0 +1,3 @@
+{
+ "description": "KVision Moment module"
+}
diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt
new file mode 100644
index 00000000..0000db83
--- /dev/null
+++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt
@@ -0,0 +1,36 @@
+/*
+ * 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
+
+internal val kVManagerMomentInit = KVManagerMoment.init()
+
+/**
+ * Internal singleton object which initializes and configures KVision Moment module.
+ */
+@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught")
+internal object KVManagerMoment {
+ fun init() {}
+
+ private val moment = try {
+ require("moment/min/moment-with-locales.js")
+ } catch (e: Throwable) {}
+}
diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt
new file mode 100644
index 00000000..9eb9d9a7
--- /dev/null
+++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt
@@ -0,0 +1,91 @@
+/*
+ * 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.moment
+
+import kotlin.js.Date
+
+@Suppress("unused")
+@JsNonModule
+@JsModule("moment")
+open external class Moment {
+ constructor(dateArray: Array<dynamic>)
+ constructor(dateString: String, patter: String)
+ constructor(dateString: String)
+ constructor(date: Date)
+ constructor()
+
+ open fun add(duration: dynamic, key: String): dynamic = definedExternally
+ open fun subtract(duration: dynamic, key: String): dynamic = definedExternally
+ open fun startOf(key: String): dynamic = definedExternally
+ open fun endOf(key: String): dynamic = definedExternally
+ open fun local(): dynamic = definedExternally
+ open fun utc(): dynamic = definedExternally
+ open fun utcOffset(): dynamic = definedExternally
+ open fun utcOffset(amount: dynamic): dynamic = definedExternally
+ open fun utcOffset(amount: dynamic, keepExistingTimeOfDay: Boolean): dynamic = definedExternally
+ open fun format(pattern: String): dynamic = definedExternally
+ open fun format(): dynamic = definedExternally
+ open fun fromNow(): dynamic = definedExternally
+ open fun fromNow(withoutSuffix: Boolean): dynamic = definedExternally
+ open fun from(moment: dynamic): dynamic = definedExternally
+ open fun from(withoutSuffix: Boolean): dynamic = definedExternally
+ open fun toNow(): dynamic = definedExternally
+ open fun toNow(withoutPrefix: Boolean): dynamic = definedExternally
+ open fun to(moment: dynamic): dynamic = definedExternally
+ open fun to(withoutPrefix: Boolean): dynamic = definedExternally
+ open fun calendar(): dynamic = definedExternally
+ open fun calendar(referenceTime: dynamic): dynamic = definedExternally
+ open fun calendar(referenceTime: dynamic, formats: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic, key: dynamic): dynamic = definedExternally
+ open fun diff(moment: dynamic, key: dynamic, floatingPoint: Boolean): dynamic = definedExternally
+ open fun valueOf(): dynamic = definedExternally
+ open fun unix(): dynamic = definedExternally
+ open fun daysInMonth(): dynamic = definedExternally
+ open fun toDate(): dynamic = definedExternally
+ open fun toArray(): dynamic = definedExternally
+ open fun toJSON(): dynamic = definedExternally
+ open fun toISOString(): dynamic = definedExternally
+ open fun toISOString(keepOffset: Boolean): dynamic = definedExternally
+ open fun toObject(): dynamic = definedExternally
+ open fun inspect(): dynamic = definedExternally
+ open fun isBefore(moment: dynamic): Boolean = definedExternally
+ open fun isBefore(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSame(moment: dynamic): Boolean = definedExternally
+ open fun isSame(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isAfter(moment: dynamic): Boolean = definedExternally
+ open fun isAfter(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSameOrBefore(moment: dynamic): Boolean = definedExternally
+ open fun isSameOrBefore(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isSameOrAfter(moment: dynamic): Boolean = definedExternally
+ open fun isSameOrAfter(moment: dynamic, key: String): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic, key: String, inclusivity: String): Boolean = definedExternally
+ open fun isBetween(firstMoment: dynamic, secondMoment: dynamic, key: String): Boolean = definedExternally
+ open fun isDST(): Boolean = definedExternally
+ open fun isDSTShifted(): Boolean = definedExternally
+ open fun isLeapYear(): Boolean = definedExternally
+ open fun locale(locale: String): dynamic = definedExternally
+ open fun locale(resetLocale: Boolean): dynamic = definedExternally
+ open fun lang(locale: String): dynamic = definedExternally
+ open fun lang(resetLocale: Boolean): dynamic = definedExternally
+}