feat(tasks): interpret plain numbers as minutes and strip prefixes

This commit is contained in:
xeruf 2024-08-15 13:16:14 +03:00
parent 9c0a688297
commit 43278a6631
2 changed files with 19 additions and 7 deletions

View File

@ -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) - `:[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) - `::[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: - `([TIME]` - list tracked times or insert timetracking with the specified offset
list tracked times) such as `-1d`, `-15 minutes`, `yesterday 17:20`, `in 2 fortnights`
- `)[TIME]` - stop timetracking with the specified offset - convenience helper to move to root (empty: stop now) - `)[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]` - complete active task and move up, with optional status description
- `<[TEXT]` - close 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` - set status for current task from text and move up (empty: Open)
- `,TEXT` - add text note (comment / description) - `,[TEXT]` - list notes or add text note (comment / description)
- TBI: `*[INT]` - set priority - can also be used in task creation, with any digit - TBI: `*[INT]` - set priority - can also be used in task creation, with any digit
- TBI: status history and creation with attribution - TBI: status history and creation with attribution
- `&` - undo last action (moving in place or upwards confirms pending actions) - `&` - 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: compress tracked time for old tasks, filter closed tasks
+ Relay: filter out task status updates within few seconds, also on client side + 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 ### Command
- Open Command characters: `_^\=$%~'"`, `{}[]` - Open Command characters: `_^\=$%~'"`, `{}[]`

View File

@ -702,10 +702,15 @@ 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(), stripped) {
Ok(date) => Some(date.to_utc()), Ok(date) => Some(date.to_utc()),
Err(_) => { Err(_) => {
warn!("Could not parse time from {str}: {e}"); warn!("Could not parse time from {str}: {e}");