korlibs / korlibs/korlibs-time
Make it easier to get the local Date
- Dominant language
- Kotlin
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
As we have found out the hard way getting the current local Date with Klock is kind of verbose and if you are not careful you can get the date in UTC which can differ from local Date for part of the day.
One might think that `DateTime.now().date` would be correct but that is the date in UTC. If you are familiar with `DateTime` vs. `DateTimeTz` one might think that you should do `DateTime.nowLocal().date` or `DateTimeTz.now().date` but those don't compile because for no discernible reason `DateTimeTz` does not have a date property like `DateTime` does. So one starting point is just add that. Without it it requires sticking a `.local` in there to convert to a `DateTime` to be able to get the `Date`
In our project I added some extension properties to get the local date, but it would be nice if Klock did something similar:
val DateTimeTz.date get() = local.date
val Date.Companion.today get() = DateTime.nowLocal().date
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the definitions of DateTimeTz, DateTime, and Date.Companion, focusing on the existing local conversion and nowLocal APIs. Confirm that local date access can be exposed through the requested properties and that callers can obtain the current local Date without the extra conversion; done means both requested expressions compile and return the local date.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100