Digging up this old thread. I have a usecase where some businesses consider 2AM or 3AM to be the end of the day, sometimes known as a closeout time.
I want to figure out what the business date is of someones particular shift. So if I finish a shift at 2023-01-02T01
5900 and the closeout time is 2
0000, then the business date for the end of the shift would be 2023-01-01. If I finish a shift at 2023-01-02T2
0000, then the business date for the end of the shift would be 2023-01-02.
Using the java api I can do this to figure it out:
zonedDateTime.toLocalDateTime().minusHours(closeoutHour).toLocalDate()
But in kotlinx.datetime we can’t do arithmetic on the LocalDateTime. However, in this case doing arithmetic on the Instant could get us wrong answers depending on daylight savings time, since the closeout time does not shift. Is there some gotcha I’m missing about the java api in this use case?