Skip to content

Gracefully handle input strings with unicode whitespace - #16

Merged
dbernheisel merged 1 commit into
dbernheisel:mainfrom
danderson:push-wrxqszokzlww
Nov 22, 2026
Merged

dbernheisel merged 1 commit into
dbernheisel:mainfrom
danderson:push-wrxqszokzlww

Conversation

@danderson

Copy link
Copy Markdown
Contributor

I was parsing Konversation IRC log files, which unfortunately uses machine-unfriendly timestamps. I encountered the string 2:58:54 PM, which parses as ~T[02:58:54] instead of the expected ~T[14:58:54]. After a lot of head scratching, I finally realized that the space before the PM is a Unicode U+202F (Narrow Non-Breaking Space), and that was causing DateTimeParser to stop prematurely and discard the PM specifier.

(You might well ask why on earth Konversation is using esoteric whitespace in timestamps. I've certainly been asking myself that.)

After a bunch of digging through Elixir and Erlang regex docs, what I think is happening is that DateTimeParser.Formatters.clean isn't canonicalizing unicode whitespace, because by default [[:space:]] only matches on pre-Unicode posix whitespace characters.

For the regression tests, I deliberately did not use the test_parsing macros, because the resulting entries in EXAMPLES.livemd repeat other examples as far as the datetime formats go, and the esoteric unicode whitespace isn't obvious to the naked eye.

@dbernheisel
dbernheisel merged commit f7bbba0 into dbernheisel:main Nov 22, 2026
0 of 3 checks passed
@dbernheisel

Copy link
Copy Markdown
Owner

Aw man! I hate those little traps! Thanks for contributing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants