Access current time from command (context) #609
Answered
by
JakeWharton
mikaelstaldal
asked this question in
Q&A
-
Is it possible to access current time from a Clikt command (or its context) in a way which can be mocked when testing the command? I can do |
Beta Was this translation helpful? Give feedback.
Answered by
JakeWharton
Aug 11, 2025
Replies: 1 comment 2 replies
-
As of Kotlin 2.2 you can add a |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
mikaelstaldal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As of Kotlin 2.2 you can add a
kotlin.time.Clock
constructor parameter with a default value ofClock.System
. If you are on an older version of Kotlin the kotlinx.datetime library can provide the same API.