BurntSushi / jiff

A date-time library for Rust that encourages you to jump into the pit of success.
The Unlicense
1.74k stars 33 forks source link

fmt: improve strptime so that it can parse adjacent values more easily #70

Closed BurntSushi closed 3 months ago

BurntSushi commented 3 months ago

Previously, strptime worked greedily. That is, specifiers like %Y matched as many ASCII digits as possible, and then tried to parse all of them into a year value.

But this meant that using %Y%m%d to parse something like 20240730 couldn't work: %Y would consume all of 20240730 and then of course fail since the value exceeds the year boundaries of Jiff.

Instead, we tweak how parsing works so that it only consumes the maximum possible number of digits given its boundaries.

Fixes #62