zio-config icon indicating copy to clipboard operation
zio-config copied to clipboard

zio.duration.Duration is always written in seconds and brakes when the duration is less than 1 second

Open egast opened this issue 4 years ago • 1 comments

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

egast avatar Nov 06 '20 12:11 egast

I think this issue is solved by #438

LGLO avatar Dec 27 '20 07:12 LGLO