about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libtime/lib.rs36
-rw-r--r--src/rt/rust_builtin.c42
2 files changed, 7 insertions, 71 deletions
diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs
index 0e67076dc08..b7dc585fc26 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,12 +1429,6 @@ 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());
 
diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c
index 6ab36f1db7a..ed077e69978 100644
--- a/src/rt/rust_builtin.c
+++ b/src/rt/rust_builtin.c
@@ -127,15 +127,6 @@ rust_list_dir_wfd_fp_buf(void* wfd) {
 }
 #endif
 
-typedef struct
-{
-    size_t fill;    // in bytes; if zero, heapified
-    size_t alloc;   // in bytes
-    uint8_t data[0];
-} rust_vec;
-
-typedef rust_vec rust_str;
-
 typedef struct {
     int32_t tm_sec;
     int32_t tm_min;
@@ -147,7 +138,6 @@ typedef struct {
     int32_t tm_yday;
     int32_t tm_isdst;
     int32_t tm_gmtoff;
-    rust_str *tm_zone;
     int32_t tm_nsec;
 } rust_tm;
 
@@ -164,8 +154,10 @@ void rust_tm_to_tm(rust_tm* in_tm, struct tm* out_tm) {
     out_tm->tm_isdst = in_tm->tm_isdst;
 }
 
-void tm_to_rust_tm(struct tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
-                   const char *zone, int32_t nsec) {
+void tm_to_rust_tm(struct tm* in_tm,
+                   rust_tm* out_tm,
+                   int32_t gmtoff,
+                   int32_t nsec) {
     out_tm->tm_sec = in_tm->tm_sec;
     out_tm->tm_min = in_tm->tm_min;
     out_tm->tm_hour = in_tm->tm_hour;
@@ -177,13 +169,6 @@ void tm_to_rust_tm(struct tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
     out_tm->tm_isdst = in_tm->tm_isdst;
     out_tm->tm_gmtoff = gmtoff;
     out_tm->tm_nsec = nsec;
-
-    if (zone != NULL) {
-        size_t size = strlen(zone);
-        assert(out_tm->tm_zone->alloc >= size);
-        memcpy(out_tm->tm_zone->data, zone, size);
-        out_tm->tm_zone->fill = size;
-    }
 }
 
 #if defined(__WIN32__)
@@ -225,7 +210,7 @@ rust_gmtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
     time_t s = sec;
     GMTIME(&s, &tm);
 
-    tm_to_rust_tm(&tm, timeptr, 0, "UTC", nsec);
+    tm_to_rust_tm(&tm, timeptr, 0, nsec);
 }
 
 void
@@ -234,28 +219,13 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
     time_t s = sec;
     LOCALTIME(&s, &tm);
 
-    const char* zone = NULL;
 #if defined(__WIN32__)
     int32_t gmtoff = -timezone;
-    wchar_t wbuffer[64] = {0};
-    char buffer[256] = {0};
-    // strftime("%Z") can contain non-UTF-8 characters on non-English locale (issue #9418),
-    // so time zone should be converted from UTF-16 string.
-    // Since wcsftime depends on setlocale() result,
-    // instead we convert it using MultiByteToWideChar.
-    if (strftime(buffer, sizeof(buffer) / sizeof(char), "%Z", &tm) > 0) {
-        // ANSI -> UTF-16
-        MultiByteToWideChar(CP_ACP, 0, buffer, -1, wbuffer, sizeof(wbuffer) / sizeof(wchar_t));
-        // UTF-16 -> UTF-8
-        WideCharToMultiByte(CP_UTF8, 0, wbuffer, -1, buffer, sizeof(buffer), NULL, NULL);
-        zone = buffer;
-    }
 #else
     int32_t gmtoff = tm.tm_gmtoff;
-    zone = tm.tm_zone;
 #endif
 
-    tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
+    tm_to_rust_tm(&tm, timeptr, gmtoff, nsec);
 }
 
 int64_t