kotlinx-datetime icon indicating copy to clipboard operation
kotlinx-datetime copied to clipboard

A number of bugs and inconsistencies with Java

Open dkhalanskyjb opened this issue 1 year ago • 1 comments

https://gist.github.com/ilma4/a5ad5b5c284969e24f4e2149a2f8b273 lists several bugs and inconsistencies.

  • [ ] kotlinx.datetime.LocalDate.parse(s) vs LocalDate.Formats.ISO.parse(s) (and the same for LocalDateTime): Java's facilities don't support having too many leading zeroes, but our parsing mechanism does, and delegating to Java prevents us from reading strings like +00000000000002022-07-16.
  • [ ] DatePeriod.parse and DateTimePeriod.parse parsing "P": it is inconsistent with ISO 8601 to parse just P without any components, so we should probably fix that.
  • [x] kotlinx.datetime.DatePeriod is always normalized unlike java.time.Duration`: this is intentional.
  • [x] kotlinx.datetime.Instant.parse: intentional.
  • [x] Different periods between two dates in Java and Kotlin: looks like Java's bug.
  • [x] kotlin.datetime.Duration max value is different from Java's: intentional.
  • [ ] kotlin.time.Duration.parseIsoString with too many digits: it is a bug that we think PT0000000000000000000000000M is an infinite duration. (Not this library's scope, though)
  • [ ] kotlin.time.Duration.parse("PT+-2H") successfully parses -2 hours: not valid ISO 8601, we can fix that. (Not this library's scope, though)

dkhalanskyjb avatar Oct 15 '24 14:10 dkhalanskyjb

https://github.com/JetBrains/kotlin/pull/5370 is the kotlin.time.Duration portion of the fixes.

dkhalanskyjb avatar Oct 16 '24 15:10 dkhalanskyjb