summaryrefslogtreecommitdiffstats
path: root/src/timetype.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-11-11 03:47:46 +0100
committerGitHub <noreply@github.com>2017-11-11 03:47:46 +0100
commit76050160d43239aee29a4f34ce161bb305ee36fc (patch)
tree7ac0563bbd255d62a0622d01cbe83bf37b966b4a /src/timetype.rs
parentf707177fd0897a701c907ec4b0a036982a9a7995 (diff)
parent2053d956af43d26238f7be9ae6acf0d60b85acad (diff)
Merge pull request #3 from matthiasbeyer/parser
Parser
Diffstat (limited to 'src/timetype.rs')
-rw-r--r--src/timetype.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs
index 8d17abd..eb840d3 100644
--- a/src/timetype.rs
+++ b/src/timetype.rs
@@ -435,6 +435,15 @@ impl TimeType {
pub fn calculate(self) -> Result<TimeType> {
do_calculate(self)
}
+
+ pub fn parse(s: &str) -> Result<TimeType> {
+ use parser;
+ match parser::timetype(s.as_bytes()) {
+ ::nom::IResult::Done(_, o) => Ok(o.into()),
+ ::nom::IResult::Error(e) => Err(KE::from(e)),
+ ::nom::IResult::Incomplete(_) => Err(KEK::UnknownParserError.into()),
+ }
+ }
}
fn do_calculate(tt: TimeType) -> Result<TimeType> {