Implement DurationUnit in JS, add doc summary and conversion test

This commit is contained in:
Ilya Gorbunov
2019-04-04 21:43:26 +03:00
parent 37c5f2c54f
commit 7977b6cdb8
5 changed files with 80 additions and 34 deletions
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.jvm.JvmMultifileClass()
@@ -8,14 +8,8 @@
package kotlin.time
//Actual typealias 'DurationUnit' has no corresponding expected declaration
//The following declaration is incompatible because modality is different:
// public final expect enum class DurationUnit : Enum<DurationUnit>
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual typealias DurationUnit = java.util.concurrent.TimeUnit
public actual fun convertDurationUnit(value: Double, sourceUnit: DurationUnit, targetUnit: DurationUnit): Double {
val sourceInTargets = targetUnit.convert(1, sourceUnit)
if (sourceInTargets > 0)