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

Add some more Duration and Instant helper utils #139

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

JonathanLennox
Copy link
Member

Some of these are moved from jitsi-media-transform's utils directory.

@@ -40,5 +44,59 @@ val Number.mins: Duration
val Number.days: Duration
get() = Duration.ofDays(this.toLong())

operator fun Duration.times(x: Int): Duration = Duration.ofNanos(toNanos() * x)
operator fun Duration.times(x: Number): Duration = this.multipliedBy(x.toLong())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accepts a Number but will not work as expected with e.g. 1.5. I see that kotlin.time.Duration already has a times(scale: Double). Can we use kotlin Duration everywhere?

bgrozev
bgrozev previously approved these changes Sep 5, 2024
The results are unexpected and undesirable for Float and Double.
@JonathanLennox JonathanLennox merged commit 6af1020 into jitsi:master Sep 6, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants