You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[package]
name = "test"version = "0.0.0"authors = [ "mike@mikedilger.com" ]
[[bin]]
name = "test"path = "main.rs"
[dependencies]
time = "*"
externcrate time;use time::strptime;fnmain(){// %m is the month number [1,12]; leading zeros are permitted but not required.let format = "%d/%m/%Y".into_string();let dates = ["24/05/2016","24/5/2016"];for date in dates.iter(){matchstrptime(*date, format.as_slice()){Ok(d) => println!("{} is valid {}, result shows as {}", date, format, d),Err(e) => println!("{} is invalid {} -- {}", date, format, e),}}}
24/05/2016 is valid %d/%m/%Y, result shows as Tm { tm_sec: 0, tm_min: 0, tm_hour: 0, tm_mday: 24, tm_mon: 4, tm_year: 116, tm_wday: 0, tm_yday: 0, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 0 }
24/5/2016 is invalid %d/%m/%Y -- Invalid month.
The text was updated successfully, but these errors were encountered:
For many format specifiers, leading zeroes are supposed to be optional: http://pubs.opengroup.org/onlinepubs/7908799/xsh/strptime.html
I have only tested %m.
The text was updated successfully, but these errors were encountered: