Skip to content

Fix Calendar.ISO.parse_time negative zero offsets in basic format - #15651

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
AlexGx:ag-iso_negative_offset-fix
Jul 22, 2026
Merged

Fix Calendar.ISO.parse_time negative zero offsets in basic format#15651
josevalim merged 1 commit into
elixir-lang:mainfrom
AlexGx:ag-iso_negative_offset-fix

Conversation

@AlexGx

@AlexGx AlexGx commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Calendar.ISO.parse_time (and functions that use it) rejects only negative zero offset in extended format (-00:00), allowing basic (-0000, -00).

iex> Calendar.ISO.parse_time("23:50:07-00:00")
{:error, :invalid_format}

iex> Calendar.ISO.parse_time("23:50:07-0000")
{:ok, {23, 50, 7, {0, 0}}} # expected {:error, :invalid_format}

iex> Calendar.ISO.parse_time("23:50:07-00")
{:ok, {23, 50, 7, {0, 0}}} # expected {:error, :invalid_format}

iex> Calendar.ISO.parse_utc_datetime("2015-01-23 23:50:07-00:00")
{:error, :invalid_format}

iex> Calendar.ISO.parse_utc_datetime("2015-01-23 23:50:07-0000")
{:ok, {2015, 1, 23, 23, 50, 7, {0, 0}}, 0} # expected: {:error, :invalid_format}

existing offset test cases fixed because they are rejecting on invalid time, not offset (were checking the wrong thing)

@josevalim
josevalim merged commit e641683 into elixir-lang:main Jul 22, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@AlexGx
AlexGx deleted the ag-iso_negative_offset-fix branch July 22, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants