mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Fix errors in how parsed time values were used
%u flag takes a value in the range of 1-7. However value needs to be stored in tm.tm_wday between 0 and 6. %y takes a two-digit year value. Subtracting 1900_i32 from it is not needed.
This commit is contained in:
+2
-2
@@ -551,7 +551,7 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
|
||||
match match_digits(s, pos, 1u, false) {
|
||||
Some(item) => {
|
||||
let (v, pos) = item;
|
||||
tm.tm_wday = v;
|
||||
tm.tm_wday = v-1_i32;
|
||||
Ok(pos)
|
||||
}
|
||||
None => Err(~"Invalid day of week")
|
||||
@@ -590,7 +590,7 @@ fn parse_type(s: &str, pos: uint, ch: char, tm: &mut Tm)
|
||||
match match_digits(s, pos, 2u, false) {
|
||||
Some(item) => {
|
||||
let (v, pos) = item;
|
||||
tm.tm_year = v - 1900_i32;
|
||||
tm.tm_year = v;
|
||||
Ok(pos)
|
||||
}
|
||||
None => Err(~"Invalid year")
|
||||
|
||||
Reference in New Issue
Block a user