diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-09-07 21:59:14 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-09-07 21:59:14 +0200 |
commit | 9054601f9a5e7802b0084d68674b90df23485248 (patch) | |
tree | 8cbf5f7a3d3658aabb6036d2c7f906fe132ed581 /src | |
parent | ccbfa776c69adb02235eacf7d72d9a2adc596f49 (diff) |
Add some kind-checking functions for TimeType
Diffstat (limited to 'src')
-rw-r--r-- | src/timetype.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs index 5df7c23..11c4458 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -78,6 +78,34 @@ impl SubAssign for TimeType { /// impl TimeType { + pub fn is_a_amount(&self) -> bool { + match *self { + TimeType::Duration(_) => true, + _ => false, + } + } + + pub fn is_moment(&self) -> bool { + match *self { + TimeType::Moment(_) => true, + _ => false, + } + } + + pub fn is_addition(&self) -> bool { + match *self { + TimeType::Addition(_, _) => true, + _ => false, + } + } + + pub fn is_subtraction(&self) -> bool { + match *self { + TimeType::Subtraction(_, _) => true, + _ => false, + } + } + pub fn seconds(i: i64) -> TimeType { TimeType::Duration(::chrono::Duration::seconds(i)) } |