korlibs-archive / klock

Multiplatform Date and time library for Kotlin

Home Page:https://korlibs.soywiz.com/klock/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

startOfDay returning incorrect value?

webfrea-k opened this issue · comments

I live in a UTC + 2 timezone.
When calling DateTime.now().startOfDay I get:
Fri, 24 Jul 2020 00:00:00 UTC
Shouldn't the call to DateTime.now().startOfDay.local return:
Thu, 23 Jul 2020 22:00:00 GMT+0200?
It currently returns:
Fri, 24 Jul 2020 02:00:00 GMT+0200

@webfrea-k @soywiz

I think it shouldn't return 2200. When you have midnight at UTC, you have 2am at GMT+2 (the night just comes earlier to GMT+2 because it's closer to the east 😅).

I've also checked this at https://www.thetimezoneconverter.com/:

image

Finally, this is not related to startOfDay, for me even strict dates work the same way:

val a = DateTime(2021, 4, 14)
val b = a.local

println(a)  // Wed, 14 Apr 2021 00:00:00 UTC
println(b)  // Wed, 14 Apr 2021 03:00:00 GMT+0300

So I guess this issue can be closed.

Looks correct. I don't remember the case I was faced with back when I opened the issue, but the above makes sense @SerVB . Closing the issue.