summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authordfhoughton <dfhoughton@gmail.com>2019-06-30 13:23:41 -0400
committerdfhoughton <dfhoughton@gmail.com>2019-06-30 13:23:41 -0400
commitf9ce85e4497669ceb235865dfe6daff9e3cf5729 (patch)
treec0257127018d84f5147c4939258b534f42495373 /src/lib.rs
parente3df19074be7c5f4a175b415291434048eb811e1 (diff)
downloadtwo-timer-f9ce85e4497669ceb235865dfe6daff9e3cf5729.zip
added parsable function
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs13
1 files changed, 13 insertions, 0 deletions
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.
///