https://kotlinlang.org logo
#kotlinx-datetime
Title
# kotlinx-datetime
c

Colton Idle

12/12/2023, 3:43 AM
According to my teammate
08:00:00/13:00:00
is a valid 8601 format for representing start + end time. Does anyone know how I'd parse that using kotlinx-datetime to get my start and end time... or maybe duration? (all I want to do is see if the current local time is within that string format of start/end)
j

jw

12/12/2023, 3:54 AM
Seems like you could write a parser for the interval to split it into its one or two parts as a first step: https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
After that you could probe the format of each part to determine its type and as to whether the built-in parser would handle it.
👍 1
If it can't, you'd have to write a parser for that part yourself.
And you definitely have to write the parser for when the second part is missing values and apply to the parsed first part
👍 1
j

Jan Skrasek

12/12/2023, 10:10 AM
There is a lot what is valid ISO 😕 https://ijmacd.github.io/rfc3339-iso8601/
😯 2
🤯 3
like a boss 1
c

Colton Idle

12/12/2023, 1:35 PM
Yeah, I just ended up doing a string split on / and then LocalTime.parse the two times.
yeah. i used to think 8601 was like a single "format", but even if you agree with your team that "we'll use 8601" you still have to actual pick a pattern