Skip to content

Commit

Permalink
move exception check to web
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhirkevich committed May 23, 2024
1 parent b82b195 commit 0a5c0b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ internal class KotlinxDatetimeCalendarModel(locale: CalendarLocale) : CalendarMo
}

override fun parse(date: String, pattern: String): CalendarDate? {
return kotlin.runCatching {
platformDateFormat.parse(date, pattern)
}.getOrNull()
return platformDateFormat.parse(date, pattern)
}

private fun Instant.toCalendarMonth(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,18 @@ internal actual class PlatformDateFormat actual constructor(private val locale:
date: String,
pattern: String
): CalendarDate? {

return LocalDate.parse(
input = date,
format = LocalDate.Format {
byUnicodePattern(pattern)
}
).atTime(Midnight)
.toInstant(TimeZone.UTC)
.toCalendarDate(TimeZone.UTC)
return try {
LocalDate.parse(
input = date,
format = LocalDate.Format {
byUnicodePattern(pattern)
}
).atTime(Midnight)
.toInstant(TimeZone.UTC)
.toCalendarDate(TimeZone.UTC)
} catch (e: Throwable) {
null
}
}

actual fun getDateInputFormat(): DateInputFormat {
Expand Down

0 comments on commit 0a5c0b1

Please sign in to comment.