Skip to content

Commit 2b5d46c

Browse files
committed
---
yaml --- r: 95149 b: refs/heads/dist-snap c: b637798 h: refs/heads/master i: 95147: 12f05e3 v: v3
1 parent a2baea4 commit 2b5d46c

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 019b131e12f49f1953a52865c1f19b025c73c06e
9+
refs/heads/dist-snap: b637798a5aa7878daa57c147028e98f2c5bc03c5
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/time.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
788788
}
789789

790790
fn parse_type(ch: char, tm: &Tm) -> ~str {
791-
//FIXME (#2350): Implement missing types.
792791
let die = || format!("strftime: can't understand this format {} ", ch);
793792
match ch {
794793
'A' => match tm.tm_wday as int {
@@ -920,10 +919,9 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
920919
parse_type('b', tm),
921920
parse_type('Y', tm))
922921
}
923-
//'W' {}
922+
'W' => format!("{:02d}", (tm.tm_yday - (tm.tm_wday - 1 + 7) % 7 + 7)
923+
/ 7),
924924
'w' => (tm.tm_wday as int).to_str(),
925-
//'X' {}
926-
//'x' {}
927925
'Y' => (tm.tm_year as int + 1900).to_str(),
928926
'y' => format!("{:02d}", (tm.tm_year as int + 1900) % 100),
929927
'Z' => tm.tm_zone.clone(),
@@ -934,7 +932,7 @@ fn do_strftime(format: &str, tm: &Tm) -> ~str {
934932
m -= h * 60_i32;
935933
format!("{}{:02d}{:02d}", sign, h, m)
936934
}
937-
//'+' {}
935+
'+' => tm.rfc3339(),
938936
'%' => ~"%",
939937
_ => die()
940938
}
@@ -1297,12 +1295,13 @@ mod tests {
12971295
assert_eq!(local.strftime("%u"), ~"5");
12981296
assert_eq!(local.strftime("%V"), ~"07");
12991297
assert_eq!(local.strftime("%v"), ~"13-Feb-2009");
1300-
// assert!(local.strftime("%W") == "06");
1298+
assert_eq!(local.strftime("%W"), ~"06");
13011299
assert_eq!(local.strftime("%w"), ~"5");
1302-
// handle "%X"
1303-
// handle "%x"
1300+
assert_eq!(local.strftime("%X"), ~"15:31:30"); // FIXME (#2350): support locale
1301+
assert_eq!(local.strftime("%x"), ~"02/13/09"); // FIXME (#2350): support locale
13041302
assert_eq!(local.strftime("%Y"), ~"2009");
13051303
assert_eq!(local.strftime("%y"), ~"09");
1304+
assert_eq!(local.strftime("%+"), ~"2009-02-13T15:31:30-08:00");
13061305
13071306
// FIXME (#2350): We should probably standardize on the timezone
13081307
// abbreviation.

branches/dist-snap/src/libstd/str.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ use option::{None, Option, Some};
105105
use ptr;
106106
use ptr::RawPtr;
107107
use to_str::ToStr;
108+
use from_str::FromStr;
108109
use uint;
109110
use vec;
110111
use vec::{OwnedVector, OwnedCopyableVector, ImmutableVector, MutableVector};
@@ -204,6 +205,11 @@ impl ToStr for ~str {
204205
fn to_str(&self) -> ~str { self.to_owned() }
205206
}
206207

208+
impl FromStr for ~str {
209+
#[inline]
210+
fn from_str(s: &str) -> Option<~str> { Some(s.to_owned()) }
211+
}
212+
207213
impl<'self> ToStr for &'self str {
208214
#[inline]
209215
fn to_str(&self) -> ~str { self.to_owned() }
@@ -214,6 +220,11 @@ impl ToStr for @str {
214220
fn to_str(&self) -> ~str { self.to_owned() }
215221
}
216222

223+
impl<'self> FromStr for @str {
224+
#[inline]
225+
fn from_str(s: &str) -> Option<@str> { Some(s.to_managed()) }
226+
}
227+
217228
/// Convert a byte to a UTF-8 string
218229
///
219230
/// # Failure
@@ -2580,13 +2591,14 @@ impl Default for @str {
25802591
#[cfg(test)]
25812592
mod tests {
25822593
use container::Container;
2583-
use option::{None, Some};
2594+
use option::{None, Some, Option};
25842595
use ptr;
25852596
use str::*;
25862597
use vec;
25872598
use vec::{Vector, ImmutableVector, CopyableVector};
25882599
use cmp::{TotalOrd, Less, Equal, Greater};
25892600
use send_str::{SendStrOwned, SendStrStatic};
2601+
use from_str::from_str;
25902602
25912603
#[test]
25922604
fn test_eq() {
@@ -3889,6 +3901,14 @@ mod tests {
38893901
assert_eq!("abcde".to_send_str(), SendStrStatic("abcde"));
38903902
assert_eq!("abcde".to_send_str(), SendStrOwned(~"abcde"));
38913903
}
3904+
3905+
#[test]
3906+
fn test_from_str() {
3907+
let owned: Option<~str> = from_str(&"string");
3908+
assert_eq!(owned, Some(~"string"));
3909+
let managed: Option<@str> = from_str(&"string");
3910+
assert_eq!(managed, Some(@"string"));
3911+
}
38923912
}
38933913
38943914
#[cfg(test)]

0 commit comments

Comments
 (0)