Skip to content

ISO8601 Timezone offset of format +0100 fails to parse #158

Closed
@jurmous

Description

@jurmous

Code which crashes:

Instant.parse("2021-12-27T22:00:00.000+0100")

It works properly with a colon inside the timezone offset

Instant.parse("2021-12-27T22:00:00.000+01:00")

It should allow formats like +01 +01:00 and +0100 but the latter is not working
https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC

Exceptions thrown:
Java:

java.time.format.DateTimeParseException: Text '2021-12-27T22:00:00.000+0100:00' could not be parsed, unparsed text found at index 26

JS:

DateTimeFormatException: DateTimeParseException: Text '2021-12-27T22:00:00.000+0100:00' could not be parsed at index 23: 2021-12-27T22:00:00.000+0100:00, at index: 23

Activity

dkhalanskyjb

dkhalanskyjb commented on Nov 23, 2021

@dkhalanskyjb
Collaborator

The actual ISO-8601 is more subtle. There are two types of formats defined there: basic and extended ones. The basic formats are basically the extended formats with delimiters removed, like 20211227T220000+0400. So, the format that you are requesting is the basic format for the offsets. We consistently support the extended formats, but not the basic ones.

Closing this issue, as it was already reported, but we would appreciate it if, under the issue I'm closing this in favor of, you shared where you encountered this mixed "extended date-time/basic offset" format.

Duplicate of #139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jurmous@dkhalanskyjb

        Issue actions

          ISO8601 Timezone offset of format +0100 fails to parse · Issue #158 · Kotlin/kotlinx-datetime