-
This code will panic when I would expect it to be a error. fn main() {
time::Date::parse("", "%B %e, %Y");
}
|
Beta Was this translation helpful? Give feedback.
Answered by
jhpratt
Nov 12, 2020
Replies: 1 comment 1 reply
-
Yes, this was a design choice made, as an invalid format description is almost certainly a programmer error. If you are using a user-inputted format description, you should validate it with In time 0.3, the parsing of the format description and the formatting/parsing itself is split into two stages, such that an invalid format description can be handled independently. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zhiburt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, this was a design choice made, as an invalid format description is almost certainly a programmer error. If you are using a user-inputted format description, you should validate it with
time::util::validate_format_string
to avoid panicking.In time 0.3, the parsing of the format description and the formatting/parsing itself is split into two stages, such that an invalid format description can be handled independently.