Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duration static factories instead of number extension properties #4119

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions libraries/stdlib/api/js-v1/kotlin.time.kt
Original file line number Diff line number Diff line change
@@ -1,85 +1,106 @@
@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
Expand Down Expand Up @@ -236,6 +257,69 @@ public final inline class Duration : kotlin.Comparable<kotlin.time.Duration> {
public final val ZERO: kotlin.time.Duration { get; }

public final fun convert(value: kotlin.Double, sourceUnit: kotlin.time.DurationUnit, targetUnit: kotlin.time.DurationUnit): kotlin.Double

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Long): kotlin.time.Duration
}
}

Expand Down
84 changes: 84 additions & 0 deletions libraries/stdlib/api/js/kotlin.time.kt
Original file line number Diff line number Diff line change
@@ -1,85 +1,106 @@
@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.days() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.days(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.days: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.hours() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.hours(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.hours: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.microseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.microseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.microseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.milliseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.milliseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.milliseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.minutes() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.minutes(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.minutes: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.nanoseconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.nanoseconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.nanoseconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Double.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Int.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
@kotlin.time.ExperimentalTime
@kotlin.Deprecated(message = "Use Duration.seconds() function instead.", replaceWith = kotlin.ReplaceWith(expression = "Duration.seconds(this)", imports = {"kotlin.time.Duration"}))
public val kotlin.Long.seconds: kotlin.time.Duration { get; }

@kotlin.SinceKotlin(version = "1.3")
Expand Down Expand Up @@ -236,6 +257,69 @@ public final inline class Duration : kotlin.Comparable<kotlin.time.Duration> {
public final val ZERO: kotlin.time.Duration { get; }

public final fun convert(value: kotlin.Double, sourceUnit: kotlin.time.DurationUnit, targetUnit: kotlin.time.DurationUnit): kotlin.Double

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun days(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun hours(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun microseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun milliseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun minutes(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun nanoseconds(value: kotlin.Long): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Double): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Int): kotlin.time.Duration

@kotlin.SinceKotlin(version = "1.5")
public final fun seconds(value: kotlin.Long): kotlin.time.Duration
}
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/stdlib/jdk8/src/kotlin/time/DurationConversions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 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.
*/

Expand All @@ -20,7 +20,7 @@ import java.time.*
@ExperimentalTime
@kotlin.internal.InlineOnly
public inline fun java.time.Duration.toKotlinDuration(): Duration =
this.seconds.seconds + this.nano.nanoseconds
Duration.seconds(this.seconds) + Duration.nanoseconds(this.nano)


/**
Expand Down
Loading