feat(tasks): interpret plain numbers as minutes and strip prefixes
This commit is contained in:
parent
9c0a688297
commit
92b4be130c
|
@ -702,7 +702,12 @@ impl Tasks {
|
||||||
/// Returns false and prints a message if parsing failed
|
/// Returns false and prints a message if parsing failed
|
||||||
pub(crate) fn track_from(&mut self, str: &str) -> bool {
|
pub(crate) fn track_from(&mut self, str: &str) -> bool {
|
||||||
// Using two libraries for better exhaustiveness, see https://github.com/uutils/parse_datetime/issues/84
|
// Using two libraries for better exhaustiveness, see https://github.com/uutils/parse_datetime/issues/84
|
||||||
match interim::parse_date_string(&str, Local::now(), interim::Dialect::Uk) {
|
let stripped = str.trim().trim_start_matches('+').trim_start_matches("in ");
|
||||||
|
if let Ok(num) = stripped.parse::<i64>() {
|
||||||
|
self.track_at(Timestamp::from(Timestamp::now().as_u64().saturating_add_signed(num * 60)));
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
match interim::parse_date_string(stripped, Local::now(), interim::Dialect::Us) {
|
||||||
Ok(date) => Some(date.to_utc()),
|
Ok(date) => Some(date.to_utc()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
match parse_datetime::parse_datetime_at_date(Local::now(), str) {
|
match parse_datetime::parse_datetime_at_date(Local::now(), str) {
|
||||||
|
|
Loading…
Reference in New Issue