You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code like "2019-10-28T14:00:00+01:00".toInstant() works ok under JVM, but unfortunately not under JS.
This is caused by js-joda problem where Instant cannot use +01:00 offsets (only Zworks here) and causes
> var Instant = require("@js-joda/core").Instant;
undefined
> Instant.parse('2019-10-28T14:00:00+01:00')
Uncaught:
DateTimeParseException: Text '2019-10-28T14:00:00+01:00' could not be parsed at index 19: 2019-10-28T14:00:00+01:00, at index: 19
at DateTimeFormatter._parseToBuilder (/Users/jakub.gwozdz/tmp/node_modules/@js-joda/core/dist/js-joda.js:6972:19)
at DateTimeFormatter.parse2 (/Users/jakub.gwozdz/tmp/node_modules/@js-joda/core/dist/js-joda.js:6933:30)
at DateTimeFormatter.parse (/Users/jakub.gwozdz/tmp/node_modules/@js-joda/core/dist/js-joda.js:6910:23)
at Function.parse (/Users/jakub.gwozdz/tmp/node_modules/@js-joda/core/dist/js-joda.js:12368:46) {
parsedString: [Function],
errorIndex: [Function],
toString: [Function]
}
Relates to #56.
I believe relying on ZonedDateTime.parse can allow more input strings than necessary, though a format can be used to limit allowed formats.
Well my use case is in using ktor-client->kotlinx.serialization (in multiplatform, js-browser included). And since the 3rd party rest api endpoint returns datetimes in 2019-10-28T14:00:00+01:00 ISO format, I cannot really use Instant class here.
Code like
"2019-10-28T14:00:00+01:00".toInstant()
works ok under JVM, but unfortunately not under JS.This is caused by js-joda problem where
Instant
cannot use+01:00
offsets (onlyZ
works here) and causessolution would be going through ZonedDateTime:
The text was updated successfully, but these errors were encountered: