From f9ce85e4497669ceb235865dfe6daff9e3cf5729 Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sun, 30 Jun 2019 13:23:41 -0400 Subject: added parsable function --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 354578b..fd1d4a7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -464,6 +464,19 @@ lazy_static! { pub static ref MATCHER: Matcher = GRAMMAR.matcher().unwrap(); } +/// Simply returns whether the given phrase is parsable as a time expression. +/// +/// # Examples +/// +/// ```rust +/// # extern crate two_timer; +/// # use two_timer::{parsable}; +/// let copacetic = parsable("5/6/69"); +/// ``` +pub fn parsable(phrase: &str) -> bool { + GRAMMAR.rx().unwrap().is_match(phrase) +} + /// Converts a time expression into a pair or timestamps and a boolean indicating whether /// the expression was literally a range, such as "9 to 11", as opposed to "9 AM", say. /// -- cgit v1.2.3