Skip to content

Failed requirement on strange time zone #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kunyavskiy opened this issue Mar 1, 2024 · 1 comment · Fixed by #360
Closed

Failed requirement on strange time zone #359

kunyavskiy opened this issue Mar 1, 2024 · 1 comment · Fixed by #360
Labels
formatters Related to parsing and formatting

Comments

@kunyavskiy
Copy link

Attempt of parsing with following (minimized) format crashes with exception saying "Failed requirement"

    val dateTimeFormatter = DateTimeComponents.Format {
        optional {
            offset(UtcOffset.Format {
               offsetHours(Padding.NONE)
               optional { offsetMinutesOfHour(Padding.NONE) }
            })
        }
    }

It's not very helpful to understand what is wrong.

@dkhalanskyjb
Copy link
Collaborator

Yes, this exception needs to be improved. A quick answer as to why the exception is thrown: the format is ambiguous. For example, +111 could be parsed as either +01:11 or +11:01. Our system recognizes this and fails instead of trying to salvage the situation.

@dkhalanskyjb dkhalanskyjb added the formatters Related to parsing and formatting label Mar 4, 2024
dkhalanskyjb added a commit that referenced this issue Mar 18, 2024
Fixes #359
Fixes #361

Additionally, remove delayed initialization of parsing to ensure that creating ambigous formats fails and document the thrown exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatters Related to parsing and formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants