|
|
@@ -9,7 +9,13 @@ lazy_static::lazy_static! { |
|
|
|
static ref ZERO_PADDED_OFFSET: regex::Regex = regex::Regex::new(r#"(?P<sign>[+-])0(?P<hr>\d)h"#).unwrap(); |
|
|
|
} |
|
|
|
|
|
|
|
fn parse_time(time_input: &str) -> NaiveTime { |
|
|
|
fn parse_time(time_input: &str, fromtz: &Tz) -> NaiveTime { |
|
|
|
let time_input = time_input.trim(); |
|
|
|
|
|
|
|
if time_input.eq_ignore_ascii_case("now") { |
|
|
|
return Utc::now().with_timezone(fromtz).time() |
|
|
|
} |
|
|
|
|
|
|
|
let time: String = time_input.split_whitespace().collect::<Vec<_>>().join(""); |
|
|
|
match NaiveTime::parse_from_str(&time, "%H:%M") { |
|
|
|
Ok(t) => return t, |
|
|
@@ -57,7 +63,7 @@ pub fn convert(from: &str, to: &str, time: &str, day: Option<String>, date: Opti |
|
|
|
Err(e) => panic!("failed to parse to tz: {} (input = '{}')", e, to), |
|
|
|
}; |
|
|
|
|
|
|
|
let tm = parse_time(time); |
|
|
|
let tm = parse_time(time, &fromtz); |
|
|
|
|
|
|
|
let dt: Date<Tz> = match date { |
|
|
|
Some(dt) => fromtz.from_local_date(&dt).unwrap(), |
|
|
|