Jelajahi Sumber

bin/tau: prevent chrono to panic instead use log:error

Dastan-glitch 4 tahun lalu
induk
melakukan
2518c1c04e
1 mengubah file dengan 6 tambahan dan 0 penghapusan
  1. 6 0
      bin/tau/tau-cli/src/util.rs

+ 6 - 0
bin/tau/tau-cli/src/util.rs

@@ -18,8 +18,14 @@ pub fn due_as_timestamp(due: &str) -> Option<i64> {
     }
     }
     let (day, month) = (due[..2].parse::<u32>().unwrap(), due[2..].parse::<u32>().unwrap());
     let (day, month) = (due[..2].parse::<u32>().unwrap(), due[2..].parse::<u32>().unwrap());
 
 
+    if day > 31 || month > 12 {
+        error!("Invalid or out-of-range date");
+        return None
+    }
+
     let mut year = Local::today().year();
     let mut year = Local::today().year();
 
 
+    // Ensure the due date is in future
     if month < Local::today().month() {
     if month < Local::today().month() {
         year += 1;
         year += 1;
     }
     }