I have a specific `Instant`. For a given `TimeZone...
# kotlinx-datetime
c
I have a specific
Instant
. For a given
TimeZone
(thus I can get a
LocalDateTime
), I want to know the very first existing hour of the next day in that timezone. For example, if I have 23h47 december 17th in France, I want 00h00 december 18th. If 00h00 december 18th doesn't exist for whatever reason, I want the very next time that happens in that timezone, however later it happens to be. How can I represent this?
Currently the best I have is this, but since KotlinX.Datetime doesn't provide these methods I guess there's a catch?
d
local.date.plus(1, DateTimeUnit.DAY).atStartOfDayIn(timeZone).toLocalDateTime(timeZone)
?
c
Perfect! Auto complete doesn't help find it, sadly :/
d
I ran into exactly that same issue with auto complete.
s
Which one doesn't show up in auto completion?
d
It's not so much that it doesn't show it, but that it's confusing that
1.days
can not be added to LocalDate or LocaleDateTime. The
.plus
method most people would expect to be able to use an operator, so I was trying
local + 1.days
and other variations.
local + (autocomplete)
doesn't provide any hints.
c
local.<tab>
gives nothing useful, I didn't think of decomposing it into a date and doing math on that It makes complete sense that it would be done this way, but I didn't think of it
@Daniel Pitts yeah, but sadly that's how timezones work 😕 Adding a day to a
LocalDateTime
makes no sense
d
Yeah, Calendaring is crazy like that.
I recently went down the rabbit hole of the iCalendar format and CalDav protocols.
c
Ohh, did you find out interesting stuff? I'm probably going to be in that rabbit hole in a few months, I'm curious
d
I found that it was more effort than it’s worth for now. I wrote a large swath of code to handle it, and it was somewhat working for my use-case, but it was all very low level and I couldn’t figure out how I wanted to actually use it in my project. Anyway, I recommend reading through all the relevant rfcs before getting started. I misunderstood a lot about it from trying to implement it while reading through it linearly.