From 2e76250edcb7a6d3f010b231dd18a0d493c0a98a Mon Sep 17 00:00:00 2001
From: xeruf <27jf@pm.me>
Date: Mon, 20 Jan 2025 21:45:25 +0100
Subject: [PATCH] fix(main): stopping past tracking with hour while stopped

---
 src/helpers.rs | 2 +-
 src/main.rs    | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/helpers.rs b/src/helpers.rs
index c22389c..3f5b897 100644
--- a/src/helpers.rs
+++ b/src/helpers.rs
@@ -86,7 +86,7 @@ pub fn parse_date_with_ref(str: &str, reference: DateTime<Local>) -> Option<Date
 }
 
 /// Turn a human-readable relative timestamp into a nostr Timestamp.
-/// - Plain number as hour, 18 hours back or 6 hours forward
+/// - Plain number as hour after given date, if none 18 hours back or 6 hours forward
 /// - Number with prefix as minute offset
 /// - Otherwise try to parse a relative date
 pub fn parse_tracking_stamp(str: &str, after: Option<DateTime<Local>>) -> Option<Timestamp> {
diff --git a/src/main.rs b/src/main.rs
index c2fa152..cb483b5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -640,7 +640,9 @@ async fn main() -> Result<()> {
                         match arg {
                             None => tasks.move_to(None),
                             Some(arg) => {
-                                if parse_tracking_stamp(arg, Local.timestamp_millis_opt(tasks.get_position_timestamped().0.as_u64() as i64 * 1000).earliest())
+                                let pos = tasks.get_position_timestamped();
+                                let time = pos.1.and_then(|_| Local.timestamp_millis_opt(pos.0.as_u64() as i64 * 1000).earliest());
+                                if parse_tracking_stamp(arg, time)
                                     .and_then(|stamp| tasks.track_at(stamp, None)).is_some() {
                                     println!("{}", tasks.times_tracked(15));
                                 }