Vitali Plagov
09/09/2020, 6:55 PMdatetime
library for the following scenario. Can you please help me with it?
I need an object with date of now with time at 10:00. Next, I need to change this object by adding one day or by subtracting one day (depending on a certain condition).
So, I made the first part:
var todayAtTen = Clock.System.todayAt(TimeZone.UTC).atTime(hour = 10, minute = 0)
but can't make a second. How can I modify this object by adding one day to it?louiscad
09/09/2020, 6:57 PMVitali Plagov
09/09/2020, 6:58 PMClock.System.todayAt(TimeZone.UTC).plus(...).atTime(hour = 10, minute = 0)
and
Clock.System.todayAt(TimeZone.UTC).minus(...).atTime(hour = 10, minute = 0)
But I will have to repeat the same commands twiceClock.System....
chain several times because the diff in above two chains is minus()
and plus()
functionsmolikuner
09/09/2020, 7:07 PMClock.System.todayAt(TimeZone.UTC).let {
if (condition) {
it.plus(...)
} else {
it.minus(...)
}
}.atTime(hour = 10, minute = 0)
Vitali Plagov
09/09/2020, 7:23 PM