All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aecor.util.JavaTimeClock.scala Maven / Gradle / Ivy

There is a newer version: 0.19.0
Show newest version
package aecor.util

import java.time.{ Instant, ZoneId }

import cats.effect.Sync

class JavaTimeClock[F[_]](underlying: java.time.Clock)(implicit F: Sync[F]) extends Clock[F] {
  override def zone: F[ZoneId] = F.delay(underlying.getZone)
  override def instant: F[Instant] = F.delay(underlying.instant())
}

object JavaTimeClock {
  def apply[F[_]: Sync](underlying: java.time.Clock): Clock[F] =
    new JavaTimeClock[F](underlying)
  def systemDefault[F[_]: Sync]: Clock[F] = apply(java.time.Clock.systemDefaultZone())
  def systemUTC[F[_]: Sync]: Clock[F] = apply(java.time.Clock.systemUTC())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy