about summary refs log tree commit diff
path: root/src/libstd/time.rs
diff options
context:
space:
mode:
authorAshok Gautham <ScriptDevil@gmail.com>2013-01-13 16:48:34 +0530
committerAshok Gautham <ScriptDevil@gmail.com>2013-01-13 17:18:10 +0530
commit406d2b3bfe6336c71b6aedd202bb896fc47b2587 (patch)
tree4b9e64a76a0bb78d3b13e86a4f858e18506757c8 /src/libstd/time.rs
parentca9358388a7deeffd9f645d08a5755248b0a7a2a (diff)
downloadrust-406d2b3bfe6336c71b6aedd202bb896fc47b2587.tar.gz
rust-406d2b3bfe6336c71b6aedd202bb896fc47b2587.zip
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.
Diffstat (limited to 'src/libstd/time.rs')
-rw-r--r--src/libstd/time.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 72132071a05..53fb51f08b3 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -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")