Marc Knaup
08/18/2020, 10:05 PMInstant
be named Timestamp
? The former is so... scientific. Not easy to grasp, esp. for a general purpose programming language.Brutus5000
08/19/2020, 9:26 AMVitali 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?Vitali Plagov
09/09/2020, 8:58 PMLocalDate
? There's a minus()
function that takes LocalDate
as an argument. But I can't understand, what should I pass in to subtract a particular period of time from it?flosch
09/12/2020, 9:13 PMAn alternative JVM implementation for Android might be needed.It should be possible to use
kotlinx-datetime
on Android when targeting 26 and higher, right? I cannot seem to import anything from the kotlinx.datetime
package. Anything else required for Android that is not mentioned here in the README?Christian Dräger
10/10/2020, 8:57 PMBohdan Yevtushenko
10/15/2020, 1:54 PMMateusz Krawczuk
10/22/2020, 10:46 AMval init = myDeviceModel.initTimestamp * 1000
var date = LocalDate().withDayOfMonth(1).toDate()
if (init > date.time) {
date = Date(init)
}
Jan Skrasek
10/25/2020, 7:22 AMNikky
10/27/2020, 10:26 AMClock.System.now().toEpochMilliseconds()
is the equivalent of System.getCurrentMillis()
?dgngulcan
11/11/2020, 7:05 PMClock
is deprecated, how can I get current date in KMM module?Darren Bell
11/19/2020, 4:10 PMleandro
12/17/2020, 12:01 AMleandro
01/19/2021, 4:07 PMmyInstant
.toLocalDateTime(TimeZone.currentSystemDefault())
.date.plus(DateTimeUnit.DateBased.MonthBased(1)).atStartOfDayIn(TimeZone.currentSystemDefault()),
Edit:
Solved, went with
.plus(DateTimePeriod(months = 1), TimeZone.currentSystemDefault())
Paul Woitaschek
01/25/2021, 10:02 AMUS/Pacific
kotlin.RuntimeException: Unable to acquire the offset at instant 2021-01-20T15:59:38.842138051Z for zone US/Pacific
I don't fully understand what's happening here. Our ios dev says this is related to this issue:
https://stackoverflow.com/questions/19819268/convert-ios-localtimezone-to-a-knowntimezone
The ios stacktraces aren't present for release frameworks but I think it boils down to this line of code:
Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())
Paul Woitaschek
01/25/2021, 5:45 PMloopDate.plus(DateTimeUnit.DateBased.DayBased(fastingDays.size))
Now this throws:
java.lang.IllegalArgumentException: Unit duration must be positive, but was 0 days.
at kotlinx.datetime.DateTimeUnit$DateBased$DayBased.<init>(DateTimeUnit.kt:68)
Instead I would prefer to have the function just return the initial date instead of throwing when adding 0 dates.
Now we always need to write != 0 checks everywhere and use the initial instancechi
01/31/2021, 3:41 PMwhy
02/05/2021, 4:49 PMCould not resolve all files for configuration ':android:debugRuntimeClasspath'.
> Could not find org.jetbrains.kotlinx:kotlinx-datetime:0.1.1.
Searched in the following locations:
- <https://dl.google.com/dl/android/maven2/org/jetbrains/kotlinx/kotlinx-datetime/0.1.1/kotlinx-datetime-0.1.1.pom>
- <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-datetime/0.1.1/kotlinx-datetime-0.1.1.pom>
- <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-datetime/0.1.1/kotlinx-datetime-0.1.1.pom>
cafonsomota
03/27/2021, 1:17 AMCalendar
object to LocalDateTime
(kotlinx) by setting the year
, month
, etc. on the constructor; and I’ve noticed that when I call .toString
it prints something like 2021-03-27T09:00 instead of 2021-03-27T09:00:00Z. What I might be doing wrong?Paul Woitaschek
03/31/2021, 10:43 AMJavier
04/04/2021, 9:32 PM2014-06-10T16:12:58-0400
?Marc Knaup
04/14/2021, 8:32 PMkotlinx-datetime
and are compiled with 1.4?kotlinx-datetime
isn’t actually compatible with Kotlin 1.5? 😱
Must be the change of Duration
from Double
to Long
.
java.lang.NoSuchMethodError: ‘kotlinx.datetime.Instant kotlinx.datetime.Instant.plus-LRDsOJo(long)’
Nikky
04/23/2021, 7:55 AMjava.util.Calendar
but i am not happy about it
fun getMondayOfWeek(year: Int, week: Int): LocalDate {
val cal = Calendar.getInstance()
cal.set(Calendar.WEEK_OF_YEAR, week)
cal.set(Calendar.YEAR, year)
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY)
return cal.time.toInstant().toKotlinInstant().toLocalDateTime(systemTZ).date
}
is there a better way ?KamilH
04/23/2021, 8:41 AMdave08
05/10/2021, 3:10 PMfun interface
? That would allow very simple overriding of now()
in unit tests... unless there are plans to add other functions to it?Marc Knaup
05/25/2021, 2:34 PMexpect enum
in kotlinx-datetime
😕
https://github.com/Kotlin/kotlinx-datetime/issues/96Marc Knaup
05/25/2021, 3:25 PMkotlinx-datetime
Instant
, LocalDate
, etc.
• uses ISO-8601 for `toString()`/`parse()`
• provides serializer
kotlin.time
Duration
OTOH
• uses human-readable output for toString()
, returns ISO-8601 for toIsoString()
, and has no parse()
• has no serializer
Still two different date/time worlds in Kotlin and usage is confusing and error-prone.LastExceed
05/29/2021, 7:07 PMNikky
06/10/2021, 12:41 PMiamthevoid
06/25/2021, 7:18 AMplus
defined in Instant.kt
[2]. How i can handle this problem?iamthevoid
06/25/2021, 7:18 AMplus
defined in Instant.kt
[2]. How i can handle this problem?2021-06-25 10:16:17.962 8268-8268/ru.rt.mlk.android.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: ru.rt.mlk.android.debug, PID: 8268
java.lang.NoSuchMethodError: No virtual method plus-LRDsOJo(J)Lkotlinx/datetime/Instant; in class Lkotlinx/datetime/Instant; or its super classes (declaration of 'kotlinx.datetime.Instant' appears in /data/app/ru.rt.mlk.android.debug-g5W8-V28KcgbkTFVKV32LQ==/base.apk!classes26.dex)
at ru.rt.mlk.shared.data.authorization.LoginRepositoryImpl.updateAuthData(LoginRepositoryImpl.kt:42)
at ru.rt.mlk.shared.data.authorization.LoginApiImpl.onAuthTokenResponse(LoginApiImpl.kt:50)
at ru.rt.mlk.shared.data.authorization.LoginApiImpl.authorize(LoginApiImpl.kt:33)
at ru.rt.mlk.login.domain.interactor.LoginInteractorImpl.ssoLogin(LoginInteractorImpl.kt:16)
at ru.rt.mlk.login.state.LoginScreenEventManagingKt$authorize$2.invokeSuspend(LoginScreenEventManaging.kt:13)
at ru.rt.mlk.login.state.LoginScreenEventManagingKt$authorize$2.invoke(Unknown Source:8)
at ru.rt.mlk.login.state.LoginScreenEventManagingKt$authorize$2.invoke(Unknown Source:2)
at ru.rt.mlk.dkmp.utils.EventsManagerExtensionsKt$runOnIo$2.invokeSuspend(EventsManagerExtensions.kt:21)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
actual operator fun plus(duration: Duration): Instant = duration.toComponents { secondsToAdd, nanosecondsToAdd ->
try {
plus(secondsToAdd, nanosecondsToAdd.toLong())
} catch (e: IllegalArgumentException) {
if (secondsToAdd > 0) MAX else MIN
} catch (e: ArithmeticException) {
if (secondsToAdd > 0) MAX else MIN
}
}
ilya.gorbunov
06/25/2021, 11:00 AM