enhance(main): track relatively with @
This commit is contained in:
parent
828114f5de
commit
eb1bafad2d
2 changed files with 9 additions and 6 deletions
|
@ -95,6 +95,7 @@ pub fn parse_tracking_stamp(str: &str, after: Option<DateTime<Local>>) -> Option
|
||||||
}
|
}
|
||||||
let stripped = str.trim().trim_start_matches('+').trim_start_matches("in ");
|
let stripped = str.trim().trim_start_matches('+').trim_start_matches("in ");
|
||||||
if let Ok(num) = stripped.parse::<i64>() {
|
if let Ok(num) = stripped.parse::<i64>() {
|
||||||
|
// Complication needed because timestamp can only add u64, but we also want reverse
|
||||||
return Some(Timestamp::from(Timestamp::now().as_u64().saturating_add_signed(num * 60)));
|
return Some(Timestamp::from(Timestamp::now().as_u64().saturating_add_signed(num * 60)));
|
||||||
}
|
}
|
||||||
parse_date(str).and_then(|time| {
|
parse_date(str).and_then(|time| {
|
||||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -358,15 +358,17 @@ async fn main() -> Result<()> {
|
||||||
continue 'repl;
|
continue 'repl;
|
||||||
}
|
}
|
||||||
Some('@') => {}
|
Some('@') => {}
|
||||||
Some(_) => {
|
Some(_) =>
|
||||||
if let Some((left, arg)) = command.split_once("@") {
|
if let Some((left, arg)) = command.split_once("@") {
|
||||||
if let Some(time) = parse_hour(arg, 20)
|
if !arg.contains(|s: char| s.is_alphabetic()) {
|
||||||
.or_else(|| parse_date(arg).map(|utc| utc.with_timezone(&Local))) {
|
let pos = tasks.get_position_timestamped();
|
||||||
command = left.to_string();
|
let time = pos.1.and_then(|_| Local.timestamp_opt(pos.0.as_u64() as i64, 0).earliest());
|
||||||
tasks.custom_time = Some(time.to_timestamp());
|
if let Some(time) = parse_tracking_stamp(arg, time) {
|
||||||
|
command = left.to_string();
|
||||||
|
tasks.custom_time = Some(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let arg = if command.len() > 1 {
|
let arg = if command.len() > 1 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue