How can I have my custom DateTimeFormat consume a ...
# kotlinx-datetime
m
How can I have my custom DateTimeFormat consume a string but return a different value during parsing? I'm trying to add support for leap seconds (
23:59:60
) which needs to subtract one second (becoming
23:59:59
). I have a function:
private fun WithTime.secondOrleapSecond() = alternativeParsing({ second() }) { chars("60") }
. This can parse the leap seconds without crashing, but (understandably) returns
23:59:0
. How can I set
seconds = 59
in this case? I found a GitHub issue about leap seconds, there was a hint of a solution but none offered.
d
m
Oh wow, thanks! Missed it 🤦 Works great.