slight cleanup for chrono::format.

This commit is contained in:
Kang Seonghoon 2015-01-04 15:11:18 +09:00
parent cde432ed8e
commit 29428d0adf
1 changed files with 4 additions and 9 deletions

View File

@ -8,7 +8,6 @@
use std::fmt;
use std::str::SendStr;
//use std::io::{IoResult, IoError, InvalidInput};
use {Datelike, Timelike};
use duration::Duration;
@ -158,11 +157,8 @@ fn format(w: &mut fmt::Formatter, date: Option<&NaiveDate>, time: Option<&NaiveT
(Some('t'), _, _, _) => try!(write!(w, "\t")),
(Some('n'), _, _, _) => try!(write!(w, "\n")),
(Some(c), _, _, _) => {
return Err(fmt::Error);
// return Err(IoError { kind: InvalidInput, desc: "invalid date/time format",
// detail: Some(format!("unsupported escape sequence %{}", c)) });
}
// TODO issue a detailed error if possible
(Some(_), _, _, _) => return Err(fmt::Error),
(None, _, _, _) => {
// if there is the next part, a single `%` and that part should be printed
@ -175,9 +171,8 @@ fn format(w: &mut fmt::Formatter, date: Option<&NaiveDate>, time: Option<&NaiveT
}
if last_was_percent { // a stray `%`
return Err(fmt::Error);
// Err(IoError { kind: InvalidInput,
// desc: "invalid date/time format: stray `%`", detail: None })
// TODO issue a detailed error if possible
Err(fmt::Error)
} else {
Ok(())
}