dawidhyzy
02/17/2025, 8:32 AMStylianos Gakis
02/17/2025, 8:49 AMSystem.currentTimeMillis() would return?
You could take that and do Instant.fromEpochMilliseconds(thisNewApi()) probablyTgo1014
02/17/2025, 8:49 AMdawidhyzy
02/17/2025, 8:52 AMdawidhyzy
02/17/2025, 8:53 AMcurrentTimeMillis is takenhfhbd
02/17/2025, 9:01 AMasClock that calls the conputeCurrentInstant (or use the unixTimeStamp and convert the instant to kotlinx Instantdawidhyzy
02/17/2025, 9:09 AMdawidhyzy
02/17/2025, 9:10 AMStylianos Gakis
02/17/2025, 9:11 AMdawidhyzy
02/17/2025, 9:13 AMInstant.now() or Clock.System.now() is calledhfhbd
02/17/2025, 9:26 AMdawidhyzy
02/17/2025, 9:30 AMdawidhyzy
02/17/2025, 9:34 AMTrueTime object that implements Clock and force it’s usage by lint rule project wisehfhbd
02/17/2025, 10:06 AMtestTimeSoure.asClock(origin = ) using the delay skipping behavior.Dmitry Khalanskiy [JB]
02/17/2025, 10:43 AMClock.System with this even when this API is available: if a user changed the device's time, they probably had a reason to do it, and we should normally respect that choice.
There's another reason why this has to be a separate `Clock`: if we don't want to respect that choice (for example, when we believe that the user may behave maliciously), then what should happen if the API is not available? Do we just fall back to the normal system clock? Do we want to block a user when we can't use the API? Do we want to print a message? Do we query our server for the timestamp? And so on.
In any case, soon, this question will be irrelevant to kotlinx-datetime, given that Clock and Instant go to the stdlib. My opinion is that the Clock implementation for TrustedTime should enter the KTX Android library: https://developer.android.com/kotlin/ktx I think it would be weird to add Android-specific implementations to the standard library.kevin.cianfarini
02/17/2025, 1:48 PMclass TrustedClock(private val client: TrustedTimeClient) : Clock {
override fun now() = Instant.fromEpochMilliseconds(
client.computeCurrentUnixEpochMillis()
)
}dawidhyzy
02/17/2025, 1:49 PMClock.TrueTime clock should be an addition and not a replacement of Clock.System. My initial assumption was incorrect.Dmitry Khalanskiy [JB]
02/17/2025, 1:49 PMcomputeCurrentUnixEpochMillis need to be a function call?kevin.cianfarini
02/17/2025, 1:51 PM