language changes: std::fmt is moved to core and now independent of std I/O.

This commit is contained in:
Kang Seonghoon 2014-05-23 23:45:12 +09:00
parent 0e7df013bf
commit 28ceb1e3db
4 changed files with 15 additions and 15 deletions

View File

@ -432,10 +432,10 @@ impl fmt::Show for DateZ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let year = self.year();
if 0 <= year && year <= 9999 {
write!(f.buf, "{:04}-{:02}-{:02}", year, self.month(), self.day())
write!(f, "{:04}-{:02}-{:02}", year, self.month(), self.day())
} else {
// ISO 8601 requires the explicit sign for out-of-range years
write!(f.buf, "{:+05}-{:02}-{:02}", year, self.month(), self.day())
write!(f, "{:+05}-{:02}-{:02}", year, self.month(), self.day())
}
}
}
@ -858,7 +858,7 @@ mod internals {
0o10 => "F?".fmt(f), 0o00 => "FE?".fmt(f), // non-canonical
0o17 => "F".fmt(f), 0o07 => "FE".fmt(f),
0o16 => "G".fmt(f), 0o06 => "GF".fmt(f),
_ => write!(f.buf, "YearFlags({})", flags),
_ => write!(f, "YearFlags({})", flags),
}
}
}
@ -1071,7 +1071,7 @@ mod internals {
impl fmt::Show for Of {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Of(of) = *self;
write!(f.buf, "Of(({} << 4) | {:#04o} /*{}*/)",
write!(f, "Of(({} << 4) | {:#04o} /*{}*/)",
of >> 4, of & 0b1111, YearFlags((of & 0b1111) as u8))
}
}
@ -1168,7 +1168,7 @@ mod internals {
impl fmt::Show for Mdf {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Mdf(mdf) = *self;
write!(f.buf, "Mdf(({} << 9) | ({} << 4) | {:#04o} /*{}*/)",
write!(f, "Mdf(({} << 9) | ({} << 4) | {:#04o} /*{}*/)",
mdf >> 9, (mdf >> 4) & 0b11111, mdf & 0b1111, YearFlags((mdf & 0b1111) as u8))
}
}

View File

@ -171,7 +171,7 @@ impl Sub<DateTimeZ,Duration> for DateTimeZ {
impl fmt::Show for DateTimeZ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "{}T{}", self.date, self.time)
write!(f, "{}T{}", self.date, self.time)
}
}

View File

@ -251,17 +251,17 @@ impl fmt::Show for Duration {
if hasdate {
// technically speaking the negative part is not the valid ISO 8601,
// but we need to print it anyway.
try!(write!(f.buf, "{}D", self.days));
try!(write!(f, "{}D", self.days));
}
if hastime {
if self.nanos == 0 {
try!(write!(f.buf, "T{}S", self.secs));
try!(write!(f, "T{}S", self.secs));
} else if self.nanos % 1_000_000 == 0 {
try!(write!(f.buf, "T{},{:03}S", self.secs, self.nanos / 1_000_000));
try!(write!(f, "T{},{:03}S", self.secs, self.nanos / 1_000_000));
} else if self.nanos % 1_000 == 0 {
try!(write!(f.buf, "T{},{:06}S", self.secs, self.nanos / 1_000));
try!(write!(f, "T{},{:06}S", self.secs, self.nanos / 1_000));
} else {
try!(write!(f.buf, "T{},{:09}S", self.secs, self.nanos));
try!(write!(f, "T{},{:09}S", self.secs, self.nanos));
}
}
Ok(())

View File

@ -193,15 +193,15 @@ impl fmt::Show for TimeZ {
(self.sec, self.frac)
};
try!(write!(f.buf, "{:02}:{:02}:{:02}", self.hour, self.min, sec));
try!(write!(f, "{:02}:{:02}:{:02}", self.hour, self.min, sec));
if nano == 0 {
Ok(())
} else if nano % 1_000_000 == 0 {
write!(f.buf, ",{:03}", nano / 1_000_000)
write!(f, ",{:03}", nano / 1_000_000)
} else if nano % 1_000 == 0 {
write!(f.buf, ",{:06}", nano / 1_000)
write!(f, ",{:06}", nano / 1_000)
} else {
write!(f.buf, ",{:09}", nano)
write!(f, ",{:09}", nano)
}
}
}