diff options
| author | bors <bors@rust-lang.org> | 2014-05-22 15:16:31 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-22 15:16:31 -0700 |
| commit | 87ad19eb78239707f1ceed43e475c6aa052efdbc (patch) | |
| tree | 35940d52f145bca81dcf73e5e7da7f3847ceb413 /src/libtime/lib.rs | |
| parent | e402e75f4eb79af09b9451f0f232f994b3e2c998 (diff) | |
| parent | e878721d70349e2055f0ef854085de92e9498fde (diff) | |
| download | rust-87ad19eb78239707f1ceed43e475c6aa052efdbc.tar.gz rust-87ad19eb78239707f1ceed43e475c6aa052efdbc.zip | |
auto merge of #14310 : pcwalton/rust/detildestr-alllibs, r=brson
r? @brson
Diffstat (limited to 'src/libtime/lib.rs')
| -rw-r--r-- | src/libtime/lib.rs | 43 |
1 files changed, 1 insertions, 42 deletions
diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 0e67076dc08..8f47a7ce2cb 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -237,21 +237,11 @@ pub struct Tm { /// for U.S. Pacific Daylight Time, the value is -7*60*60 = -25200. pub tm_gmtoff: i32, - /// Abbreviated name for the time zone that was used to compute this broken-down time value. - /// For example, U.S. Pacific Daylight Time is "PDT". - pub tm_zone: ~str, - /// Nanoseconds after the second – [0, 10<sup>9</sup> - 1] pub tm_nsec: i32, } pub fn empty_tm() -> Tm { - // 64 is the max size of the timezone buffer allocated on windows - // in rust_localtime. In glibc the max timezone size is supposedly 3. - let mut zone = StrBuf::new(); - for _ in range(0, 64) { - zone.push_char(' ') - } Tm { tm_sec: 0_i32, tm_min: 0_i32, @@ -263,7 +253,6 @@ pub fn empty_tm() -> Tm { tm_yday: 0_i32, tm_isdst: 0_i32, tm_gmtoff: 0_i32, - tm_zone: zone.into_owned(), tm_nsec: 0_i32, } } @@ -745,7 +734,6 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, StrBuf> { 'Z' => { if match_str(s, pos, "UTC") || match_str(s, pos, "GMT") { tm.tm_gmtoff = 0_i32; - tm.tm_zone = "UTC".to_owned(); Ok(pos + 3u) } else { // It's odd, but to maintain compatibility with c's @@ -770,7 +758,6 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, StrBuf> { let (v, pos) = item; if v == 0_i32 { tm.tm_gmtoff = 0_i32; - tm.tm_zone = "UTC".to_owned(); } Ok(pos) @@ -801,7 +788,6 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, StrBuf> { tm_yday: 0_i32, tm_isdst: 0_i32, tm_gmtoff: 0_i32, - tm_zone: "".to_owned(), tm_nsec: 0_i32, }; let mut pos = 0u; @@ -848,7 +834,6 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, StrBuf> { tm_yday: tm.tm_yday, tm_isdst: tm.tm_isdst, tm_gmtoff: tm.tm_gmtoff, - tm_zone: tm.tm_zone.clone(), tm_nsec: tm.tm_nsec, }) } else { result } @@ -1050,7 +1035,7 @@ pub fn strftime(format: &str, tm: &Tm) -> StrBuf { 'w' => (tm.tm_wday as int).to_str().to_strbuf(), 'Y' => (tm.tm_year as int + 1900).to_str().to_strbuf(), 'y' => format_strbuf!("{:02d}", (tm.tm_year as int + 1900) % 100), - 'Z' => tm.tm_zone.to_strbuf(), + 'Z' => "".to_strbuf(), // FIXME(pcwalton): Implement this. 'z' => { let sign = if tm.tm_gmtoff > 0_i32 { '+' } else { '-' }; let mut m = num::abs(tm.tm_gmtoff) / 60_i32; @@ -1176,7 +1161,6 @@ mod tests { assert_eq!(utc.tm_yday, 43_i32); assert_eq!(utc.tm_isdst, 0_i32); assert_eq!(utc.tm_gmtoff, 0_i32); - assert_eq!(utc.tm_zone, "UTC".to_owned()); assert_eq!(utc.tm_nsec, 54321_i32); } @@ -1198,12 +1182,6 @@ mod tests { assert_eq!(local.tm_yday, 43_i32); assert_eq!(local.tm_isdst, 0_i32); assert_eq!(local.tm_gmtoff, -28800_i32); - - // FIXME (#2350): We should probably standardize on the timezone - // abbreviation. - let zone = &local.tm_zone; - assert!(*zone == "PST".to_owned() || *zone == "Pacific Standard Time".to_owned()); - assert_eq!(local.tm_nsec, 54321_i32); } @@ -1246,7 +1224,6 @@ mod tests { assert!(tm.tm_wday == 0_i32); assert!(tm.tm_isdst == 0_i32); assert!(tm.tm_gmtoff == 0_i32); - assert!(tm.tm_zone == "".to_owned()); assert!(tm.tm_nsec == 0_i32); } Err(_) => () @@ -1270,7 +1247,6 @@ mod tests { assert!(tm.tm_yday == 0_i32); assert!(tm.tm_isdst == 0_i32); assert!(tm.tm_gmtoff == 0_i32); - assert!(tm.tm_zone == "".to_owned()); assert!(tm.tm_nsec == 12340000_i32); } } @@ -1382,10 +1358,6 @@ mod tests { assert!(test("6", "%w")); assert!(test("2009", "%Y")); assert!(test("09", "%y")); - assert!(strptime("UTC", "%Z").unwrap().tm_zone == - "UTC".to_owned()); - assert!(strptime("PST", "%Z").unwrap().tm_zone == - "".to_owned()); assert!(strptime("-0000", "%z").unwrap().tm_gmtoff == 0); assert!(strptime("-0800", "%z").unwrap().tm_gmtoff == @@ -1457,22 +1429,9 @@ mod tests { assert_eq!(local.strftime("%Y"), "2009".to_strbuf()); assert_eq!(local.strftime("%y"), "09".to_strbuf()); assert_eq!(local.strftime("%+"), "2009-02-13T15:31:30-08:00".to_strbuf()); - - // FIXME (#2350): We should probably standardize on the timezone - // abbreviation. - let zone = local.strftime("%Z"); - assert!(zone == "PST".to_strbuf() || zone == "Pacific Standard Time".to_strbuf()); - assert_eq!(local.strftime("%z"), "-0800".to_strbuf()); assert_eq!(local.strftime("%%"), "%".to_strbuf()); - // FIXME (#2350): We should probably standardize on the timezone - // abbreviation. - let rfc822 = local.rfc822(); - let prefix = "Fri, 13 Feb 2009 15:31:30 ".to_strbuf(); - assert!(rfc822 == format_strbuf!("{}PST", prefix) || - rfc822 == format_strbuf!("{}Pacific Standard Time", prefix)); - assert_eq!(local.ctime(), "Fri Feb 13 15:31:30 2009".to_strbuf()); assert_eq!(local.rfc822z(), "Fri, 13 Feb 2009 15:31:30 -0800".to_strbuf()); assert_eq!(local.rfc3339(), "2009-02-13T15:31:30-08:00".to_strbuf()); |
