Skip to content

Commit

Permalink
Remove unused conversion modes
Browse files Browse the repository at this point in the history
  • Loading branch information
rautenrieth-da committed Oct 25, 2021
1 parent 28fd54e commit f993dd1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ object TimestampConversion {
throw new IllegalArgumentException(
s"Conversion of $t to microsecond granularity would result in loss of precision."
)
case ConversionMode.Up => t.plusNanos(1000L - fractionNanos)
case ConversionMode.Down => t.plusNanos(-fractionNanos)
case ConversionMode.HalfUp =>
t.plusNanos(if (fractionNanos >= 500L) 1000L - fractionNanos else -fractionNanos)
}
Expand All @@ -74,12 +72,6 @@ object TimestampConversion {
/** Throw an exception if the input can not be represented in microsecond resolution */
case object Exact extends ConversionMode

/** Round up to the nearest microsecond */
case object Up extends ConversionMode

/** Round down to the nearest microsecond */
case object Down extends ConversionMode

/** Round to the nearest microsecond */
case object HalfUp extends ConversionMode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,6 @@ class TimestampConversionSpec
}

"given a valid nanosecond timestamp" should {
"round down" in forAll(anyTimeInRange) { ts =>
val protoTs = fromInstant(ts)
val down = toLf(protoTs, ConversionMode.Down)
down.toInstant should be <= ts
down.toInstant should be > ts.plusNanos(-1000)
}

"round up" in forAll(anyTimeInRange) { ts =>
val protoTs = fromInstant(ts)
val up = toLf(protoTs, ConversionMode.Up)
up.toInstant should be >= ts
up.toInstant should be < ts.plusNanos(1000)
}

"round half up" in forAll(anyTimeInRange) { ts =>
val protoTs = fromInstant(ts)
val halfUp = toLf(protoTs, ConversionMode.HalfUp)
Expand Down

0 comments on commit f993dd1

Please sign in to comment.