Support Date creation from components (year, month, day, hour, minutes, etc)
Closed this issue · 1 comments
marcantoinefortier commented
Currently, we can only create a Date
instance using 3 methods :
val now: Date
fun fromISO8601(isoDate: String): Date
fun fromEpochMillis(epoch: Long): Date
That would be great if we could create a date from datetime components, such as this example :
fun fromComponents(
year: String, // YYYY
month: String, // MM
day: String // DD,
hours: String = "00", // HH
minutes: String = "00", // MM
seconds: String = "00", // SS
): Date
This new method could itself format a ISO-8601 compliant string a reuse fromISO8601
under the hood.
marcantoinefortier commented
Nevermind, we should instead use Klock which littrally support this use case. See https://github.com/korlibs/klock/blob/a7a4908e8bb6847ae69d53e8e1f9d072a8054bae/klock/src/commonMain/kotlin/com/soywiz/klock/Date.kt#L17