zio-config
zio-config copied to clipboard
zio.duration.Duration is always written in seconds and brakes when the duration is less than 1 second
The zio.duration.Duration
type is always written in seconds and outputs 0 seconds
when the Duration
is less than 1 second.
The problem is in the implementation of the write function ZioDurationType
(in PropertyType.scala
):
case object ZioDurationType extends PropertyType[String, zio.duration.Duration] {
def read(value: String): Either[PropertyReadError[String], zio.duration.Duration] =
attempt(zio.duration.Duration.fromScala(Duration.apply(value)), _ => PropertyReadError(value, "duration"))
def write(value: zio.duration.Duration): String = Duration.apply(value.getSeconds, TimeUnit.SECONDS).toString()
}```
`value.getSeconds` returns a `Long` instead of a Double, so it can never write `Duration` in seconds that are less than 1 second
I think this issue is solved by #438