Skip to content

Commit

Permalink
Fix errors in how parsed time values were used
Browse files Browse the repository at this point in the history
%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.
  • Loading branch information
ScriptDevil committed Jan 13, 2013
1 parent ca93583 commit 406d2b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libstd/time.rs
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 406d2b3

Please sign in to comment.