From edcc3e4956a95948fa6cdd48b69a3509db6cd2d3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 28 Jan 2021 12:37:43 +0300 Subject: [PATCH] remove unnecessary utils.kt --- .../kotlin/ru/inr/mass/data/proto/ProtoNumassPoint.kt | 11 ++++++++--- .../src/main/kotlin/ru/inr/mass/data/proto/utils.kt | 10 ---------- 2 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/utils.kt diff --git a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/ProtoNumassPoint.kt b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/ProtoNumassPoint.kt index eaaa1f7..781666e 100644 --- a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/ProtoNumassPoint.kt +++ b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/ProtoNumassPoint.kt @@ -115,11 +115,16 @@ internal class ProtoNumassPoint( public class ProtoBlock( override val channel: Int, private val block: Point.Channel.Block, - public val parent: NumassPoint? = null, + parent: NumassPoint? = null, ) : NumassBlock { override val startTime: Instant - get() = epochNanoTime(block.time) + get(){ + val nanos = block.time + val seconds = Math.floorDiv(nanos, 1e9.toInt().toLong()) + val reminder = (nanos % 1e9).toInt() + return Instant.ofEpochSecond(seconds, reminder.toLong()) + } override val length: Duration = when { block.length > 0 -> Duration.ofNanos(block.length) @@ -150,7 +155,7 @@ public class ProtoBlock( }.asFlow() } else { - emptyFlow() + emptyFlow() } diff --git a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/utils.kt b/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/utils.kt deleted file mode 100644 index 49c7609..0000000 --- a/numass-data-proto/src/main/kotlin/ru/inr/mass/data/proto/utils.kt +++ /dev/null @@ -1,10 +0,0 @@ -package ru.inr.mass.data.proto - -import java.time.Instant - - -internal fun epochNanoTime(nanos: Long): Instant { - val seconds = Math.floorDiv(nanos, 1e9.toInt().toLong()) - val reminder = (nanos % 1e9).toInt() - return Instant.ofEpochSecond(seconds, reminder.toLong()) -} \ No newline at end of file