TimeParser into i64. Generic argument across create_reminder. Some more work on natural inc. splitting off first args and calling the subprocess

This commit is contained in:
jude
2020-09-19 15:20:43 +01:00
parent 980a8d2a9c
commit 8e99cc088a
7 changed files with 95 additions and 11 deletions

View File

@ -11,6 +11,7 @@ use std::fmt::{
use chrono_tz::Tz;
use chrono::TimeZone;
use std::convert::TryFrom;
#[derive(Debug)]
pub enum InvalidTime {
@ -40,6 +41,14 @@ pub struct TimeParser {
parse_type: ParseType,
}
impl TryFrom<&TimeParser> for i64 {
type Error = InvalidTime;
fn try_from(value: &TimeParser) -> Result<Self, Self::Error> {
value.timestamp()
}
}
impl TimeParser {
pub fn new(input: String, timezone: Tz) -> Self {
let inverted = if input.starts_with("-") {