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::fmt;
use std::str::SendStr; use std::str::SendStr;
//use std::io::{IoResult, IoError, InvalidInput};
use {Datelike, Timelike}; use {Datelike, Timelike};
use duration::Duration; 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('t'), _, _, _) => try!(write!(w, "\t")),
(Some('n'), _, _, _) => try!(write!(w, "\n")), (Some('n'), _, _, _) => try!(write!(w, "\n")),
(Some(c), _, _, _) => { // TODO issue a detailed error if possible
return Err(fmt::Error); (Some(_), _, _, _) => return Err(fmt::Error),
// return Err(IoError { kind: InvalidInput, desc: "invalid date/time format",
// detail: Some(format!("unsupported escape sequence %{}", c)) });
}
(None, _, _, _) => { (None, _, _, _) => {
// if there is the next part, a single `%` and that part should be printed // 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 `%` if last_was_percent { // a stray `%`
return Err(fmt::Error); // TODO issue a detailed error if possible
// Err(IoError { kind: InvalidInput, Err(fmt::Error)
// desc: "invalid date/time format: stray `%`", detail: None })
} else { } else {
Ok(()) Ok(())
} }