Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package cats.effect
import cats.effect.std.Console
import cats.effect.tracing.Tracing

import java.time.Instant
import java.time.{Instant, ZonedDateTime}
import java.util.concurrent.{CompletableFuture, CompletionStage}

private[effect] abstract class IOCompanionPlatform { this: IO.type =>
Expand Down Expand Up @@ -124,6 +124,8 @@ private[effect] abstract class IOCompanionPlatform { this: IO.type =>

def realTimeInstant: IO[Instant] = asyncForIO.realTimeInstant

def realTimeZonedDateTime: IO[ZonedDateTime] = asyncForIO.realTimeZonedDateTime

/**
* Reads a line as a string from the standard input using the platform's default charset, as
* per `java.nio.charset.Charset.defaultCharset()`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@

package cats.effect.kernel

import java.time.Instant
import java.time.{Instant, ZoneOffset, ZonedDateTime}

private[effect] trait ClockPlatform[F[_]] extends Serializable { self: Clock[F] =>
def realTimeInstant: F[Instant] = {
self.applicative.map(self.realTime)(d => Instant.EPOCH.plusNanos(d.toNanos))
}

def realTimeZonedDateTime: F[ZonedDateTime] =
self.applicative.map(realTimeInstant)(d => ZonedDateTime.ofInstant(d, ZoneOffset.UTC))
}
Loading