https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Andrew

06/14/2020, 7:15 PM
For implementing a date object in KMP is the best solution so far to make a "expect class" with full implementation on each platform?
e

edenman

06/14/2020, 7:21 PM
i think so, yeah
there’s a few libraries you can try
https://github.com/erikc5000/island-time looks pretty good but i haven’t used it yet
👍 1
s

saket

06/14/2020, 8:00 PM
Island time looks interesting. Will try it out!
I've used klock in the past: https://github.com/korlibs/klock
a

Andrew

06/14/2020, 8:14 PM
Island time is a good name for a datetime library, if there are every any bugs or you never finish it, you can say its FAD because "Island time"
r

ritesh

06/15/2020, 6:18 PM
@Andrew You probably won’t need full implementation (though do you?). You can just add few expect functions like parsing the date and formatting it as per the UI. These are merely few lines of code. You can also make your custom representation of date follow
Comparable
interface if you want to sort things. In my experience (so far) I haven’t had the need to import a full date library, just few expect functions are enough.
👍 1
a

Andrew

06/15/2020, 6:32 PM
Yes I will have to look at my use cases before making a decision. So far the 2 main ones are date only where I need time spans or day of the week (like Mon/Tues). The other is timestamp for checking things like "Is timestamp older than 1 hour ago"