Skip to content

Commit

Permalink
Rename TimeZone -> StaticTimeZone
Browse files Browse the repository at this point in the history
Commit datetime@e6012ba003a8f5949510dea0f9ff334234202b07 caused this. All the time zones we want to build are static (available throughout the program).
  • Loading branch information
ogham committed Nov 18, 2015
1 parent 9ed0678 commit 34c9883
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions bin/build-data-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ impl DataCrate {
}

try!(writeln!(base_w, "\n\n"));
try!(writeln!(base_w, "pub fn lookup(input: &str) -> Option<TimeZone<'static>> {{"));
try!(writeln!(base_w, "pub fn lookup(input: &str) -> Option<&'static StaticTimeZone<'static>> {{"));
for name in &keys {
try!(writeln!(base_w, " if input == {:?} {{", name));
try!(writeln!(base_w, " return Some({});", sanitise_name(name).replace("/", "::")));
try!(writeln!(base_w, " return Some(&{});", sanitise_name(name).replace("/", "::")));
try!(writeln!(base_w, " }}"));
}
try!(writeln!(base_w, " return None;"));
Expand All @@ -167,7 +167,7 @@ impl DataCrate {
try!(writeln!(w, "{}", WARNING_HEADER));
try!(writeln!(w, "{}", ZONEINFO_HEADER));

try!(writeln!(w, "pub const ZONE: TimeZone<'static> = TimeZone {{"));
try!(writeln!(w, "pub static ZONE: StaticTimeZone<'static> = StaticTimeZone {{"));
try!(writeln!(w, " name: {:?},", name));
try!(writeln!(w, " fixed_timespans: FixedTimespanSet {{"));

Expand All @@ -176,7 +176,7 @@ impl DataCrate {
try!(writeln!(w, " first: FixedTimespan {{"));
try!(writeln!(w, " offset: {:?}, // UTC offset {:?}, DST offset {:?}", set.first.total_offset(), set.first.utc_offset, set.first.dst_offset));
try!(writeln!(w, " is_dst: {:?},", set.first.dst_offset != 0));
try!(writeln!(w, " name: {:?},", set.first.name));
try!(writeln!(w, " name: Cow::Borrowed({:?}),", set.first.name));
try!(writeln!(w, " }},"));

try!(writeln!(w, " rest: &["));
Expand All @@ -189,7 +189,7 @@ impl DataCrate {
// comment in the data crate.
try!(writeln!(w, " offset: {:?}, // UTC offset {:?}, DST offset {:?}", t.1.total_offset(), t.1.utc_offset, t.1.dst_offset));
try!(writeln!(w, " is_dst: {:?},", t.1.dst_offset != 0));
try!(writeln!(w, " name: {:?},", t.1.name));
try!(writeln!(w, " name: Cow::Borrowed({:?}),", t.1.name));
try!(writeln!(w, " }}),"));
}
try!(writeln!(w, " ]}},"));
Expand Down Expand Up @@ -219,9 +219,10 @@ const WARNING_HEADER: &'static str = r##"
"##;

const ZONEINFO_HEADER: &'static str = r##"
use datetime::zone::{TimeZone, FixedTimespanSet, FixedTimespan};
use std::borrow::Cow;
use datetime::zone::{StaticTimeZone, FixedTimespanSet, FixedTimespan};
"##;

const MOD_HEADER: &'static str = r##"
use datetime::zone::TimeZone;
use datetime::zone::StaticTimeZone;
"##;

0 comments on commit 34c9883

Please sign in to comment.