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:
Ashok Gautham 2013-01-13 16:48:34 +05:30
parent ca9358388a
commit 406d2b3bfe

View file

@ -551,7 +551,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
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 @@ priv fn do_strptime(s: &str, format: &str) -> Result<Tm, ~str> {
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")