Implement storage routines for periodic scheduler

This commit is contained in:
Eike Kettner
2020-03-08 13:56:23 +01:00
parent 1e598bd902
commit 616c333fa5
7 changed files with 152 additions and 13 deletions

View File

@ -28,6 +28,8 @@ case class Timestamp(value: Instant) {
def atZone(zone: ZoneId): ZonedDateTime =
value.atZone(zone)
def atUTC: ZonedDateTime = atZone(Timestamp.UTC)
def asString: String = value.toString
}
@ -39,6 +41,9 @@ object Timestamp {
def current[F[_]: Sync]: F[Timestamp] =
Sync[F].delay(Timestamp(Instant.now))
def from(zd: ZonedDateTime): Timestamp =
Timestamp(zd.toInstant)
implicit val encodeTimestamp: Encoder[Timestamp] =
BaseJsonCodecs.encodeInstantEpoch.contramap(_.value)