diff options
author | dfhoughton <dfhoughton@gmail.com> | 2019-06-30 13:23:41 -0400 |
---|---|---|
committer | dfhoughton <dfhoughton@gmail.com> | 2019-06-30 13:23:41 -0400 |
commit | f9ce85e4497669ceb235865dfe6daff9e3cf5729 (patch) | |
tree | c0257127018d84f5147c4939258b534f42495373 /src/lib.rs | |
parent | e3df19074be7c5f4a175b415291434048eb811e1 (diff) | |
download | two-timer-f9ce85e4497669ceb235865dfe6daff9e3cf5729.zip |
added parsable function
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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. /// |