time-rs/time

parsing a date with a year with last_two

Closed this issue · 3 comments

I am trying to parse this date 30.09.24 with this code:

time::Date::parse(
    date,
    &time::format_description::parse("[day].[month].[year repr:last_two]")
        .context("Could not create format description")?,
)
.context("Could not parse date")?

I am getting this error:

the `Parsed` struct did not include enough information to construct the type

I have no idea what I am doing wrong here.

The last two digits of a year do not unambiguously identify what year should be used.

The last two digits of a year do not unambiguously identify what year should be used.

Maybe there could be a way to add additional info about the year so that it works.

You can go through the Parsed struct manually, setting the full year while using the information from the two digits.