Open patrykcelinski opened 4 years ago
https://github.com/SuperXtra/githubApi/blob/9f55aed6b5491cfd8849cc0dfd6a36333d144756/app/Module.scala#L18
Although java Clock is perfectly fine. I can also recommend you to use cats.Clock[F] typeclass. https://typelevel.org/cats-effect/datatypes/clock.html
Clock
cats.Clock[F]
In this project you don't need it - they want futures. But if you will go into F[ _ ] this clock might be useful.
F[ _ ]
class SomeService[F[_]: Sync: Clock]( ) { private def today: F[LocalDate] = { Clock[F].realTime(MILLISECONDS).map(new LocalDate(_)) } private def secondsToMidnight: F[Int] = { import com.github.nscala_time.time.Implicits._ for { timeNow <- Clock[F].realTime(MILLISECONDS) now = new DateTime(timeNow) midnight = now + (1 day) withTimeAtStartOfDay () } yield Seconds.secondsBetween(now, midnight).getSeconds }
Apart from clock joda time is helpful.
Its just side info. Don't waste time on this issue.
https://github.com/SuperXtra/githubApi/blob/9f55aed6b5491cfd8849cc0dfd6a36333d144756/app/Module.scala#L18
Although java
Clock
is perfectly fine. I can also recommend you to usecats.Clock[F]
typeclass. https://typelevel.org/cats-effect/datatypes/clock.htmlIn this project you don't need it - they want futures. But if you will go into
F[ _ ]
this clock might be useful.