From 43278a663161f081f93e5858d8ce8d54c8a34b0e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 15 Aug 2024 13:16:14 +0300 Subject: [PATCH] feat(tasks): interpret plain numbers as minutes and strip prefixes --- README.md | 17 ++++++++++++----- src/tasks.rs | 9 +++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 05c6c5b..0df816f 100644 --- a/README.md +++ b/README.md @@ -107,13 +107,13 @@ Dot or slash can be repeated to move to parent tasks before acting. - `:[IND][PROP]` - add property column PROP at IND or end, if it already exists remove property column PROP or IND (1-indexed) - `::[PROP]` - Sort by property PROP (multiple space-separated values allowed) -- `([TIME]` - insert timetracking with the specified offset such as `-1d`, `-15 minutes` or `yesterday 17:20` (empty: - list tracked times) -- `)[TIME]` - stop timetracking with the specified offset - convenience helper to move to root (empty: stop now) +- `([TIME]` - list tracked times or insert timetracking with the specified offset + such as `-1d`, `-15 minutes`, `yesterday 17:20`, `in 2 fortnights` +- `)[TIME]` - stop timetracking with optional offset - also convenience helper to move to root - `>[TEXT]` - complete active task and move up, with optional status description - `<[TEXT]` - close active task and move up, with optional status description -- `!TEXT` - set status for current task from text and move up (empty to open) -- `,TEXT` - add text note (comment / description) +- `!TEXT` - set status for current task from text and move up (empty: Open) +- `,[TEXT]` - list notes or add text note (comment / description) - TBI: `*[INT]` - set priority - can also be used in task creation, with any digit - TBI: status history and creation with attribution - `&` - undo last action (moving in place or upwards confirms pending actions) @@ -187,6 +187,13 @@ Considering to use Calendar: https://github.com/nostr-protocol/nips/blob/master/ + Relay: compress tracked time for old tasks, filter closed tasks + Relay: filter out task status updates within few seconds, also on client side +### Fixes + +- New Relay does not load until next is added + https://github.com/rust-nostr/nostr/issues/533 +- Handle event sending rejections (e.g. permissions) +- Recursive filter handling + ### Command - Open Command characters: `_^\=$%~'"`, `{}[]` diff --git a/src/tasks.rs b/src/tasks.rs index 7b723cd..0c903fd 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -702,10 +702,15 @@ impl Tasks { /// Returns false and prints a message if parsing failed 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 - 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::() { + 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()), Err(e) => { - match parse_datetime::parse_datetime_at_date(Local::now(), str) { + match parse_datetime::parse_datetime_at_date(Local::now(), stripped) { Ok(date) => Some(date.to_utc()), Err(_) => { warn!("Could not parse time from {str}: {e}");