paavohtl Claude Opus 4.6 (1M context) commited on
Commit
7b6557b
·
1 Parent(s): 159ee14

refactor: use chrono for timestamp in test runner

Browse files

Replace hand-rolled days_to_ymd/chrono_lite with chrono::Local::now().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Cargo.lock CHANGED
@@ -64,6 +64,15 @@ version = "0.2.2"
64
  source = "registry+https://github.com/rust-lang/crates.io-index"
65
  checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
66
 
 
 
 
 
 
 
 
 
 
67
  [[package]]
68
  name = "arboard"
69
  version = "3.6.1"
@@ -285,6 +294,19 @@ dependencies = [
285
  "libc",
286
  ]
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  [[package]]
289
  name = "clipboard-win"
290
  version = "5.4.1"
@@ -804,6 +826,30 @@ version = "3.5.1"
804
  source = "registry+https://github.com/rust-lang/crates.io-index"
805
  checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f"
806
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
807
  [[package]]
808
  name = "icrate"
809
  version = "0.0.4"
@@ -1465,6 +1511,9 @@ version = "0.1.0"
1465
  [[package]]
1466
  name = "openwa-test-runner"
1467
  version = "0.1.0"
 
 
 
1468
 
1469
  [[package]]
1470
  name = "openwa-wormkit"
 
64
  source = "registry+https://github.com/rust-lang/crates.io-index"
65
  checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
66
 
67
+ [[package]]
68
+ name = "android_system_properties"
69
+ version = "0.1.5"
70
+ source = "registry+https://github.com/rust-lang/crates.io-index"
71
+ checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
72
+ dependencies = [
73
+ "libc",
74
+ ]
75
+
76
  [[package]]
77
  name = "arboard"
78
  version = "3.6.1"
 
294
  "libc",
295
  ]
296
 
297
+ [[package]]
298
+ name = "chrono"
299
+ version = "0.4.44"
300
+ source = "registry+https://github.com/rust-lang/crates.io-index"
301
+ checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
302
+ dependencies = [
303
+ "iana-time-zone",
304
+ "js-sys",
305
+ "num-traits",
306
+ "wasm-bindgen",
307
+ "windows-link",
308
+ ]
309
+
310
  [[package]]
311
  name = "clipboard-win"
312
  version = "5.4.1"
 
826
  source = "registry+https://github.com/rust-lang/crates.io-index"
827
  checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f"
828
 
829
+ [[package]]
830
+ name = "iana-time-zone"
831
+ version = "0.1.65"
832
+ source = "registry+https://github.com/rust-lang/crates.io-index"
833
+ checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
834
+ dependencies = [
835
+ "android_system_properties",
836
+ "core-foundation-sys",
837
+ "iana-time-zone-haiku",
838
+ "js-sys",
839
+ "log",
840
+ "wasm-bindgen",
841
+ "windows-core",
842
+ ]
843
+
844
+ [[package]]
845
+ name = "iana-time-zone-haiku"
846
+ version = "0.1.2"
847
+ source = "registry+https://github.com/rust-lang/crates.io-index"
848
+ checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
849
+ dependencies = [
850
+ "cc",
851
+ ]
852
+
853
  [[package]]
854
  name = "icrate"
855
  version = "0.0.4"
 
1511
  [[package]]
1512
  name = "openwa-test-runner"
1513
  version = "0.1.0"
1514
+ dependencies = [
1515
+ "chrono",
1516
+ ]
1517
 
1518
  [[package]]
1519
  name = "openwa-wormkit"
crates/openwa-test-runner/Cargo.toml CHANGED
@@ -7,3 +7,6 @@ description = "Headless replay test runner with concurrent execution"
7
  [[bin]]
8
  name = "openwa-test"
9
  path = "src/main.rs"
 
 
 
 
7
  [[bin]]
8
  name = "openwa-test"
9
  path = "src/main.rs"
10
+
11
+ [dependencies]
12
+ chrono = "0.4"
crates/openwa-test-runner/src/main.rs CHANGED
@@ -562,7 +562,7 @@ fn main() {
562
  });
563
 
564
  // Create run directory
565
- let timestamp = chrono_lite();
566
  let run_dir = PathBuf::from(RUNS_DIR).join(&timestamp);
567
  let _ = fs::create_dir_all(&run_dir);
568
  let run_dir = strip_unc(fs::canonicalize(&run_dir).unwrap_or(run_dir));
@@ -593,38 +593,6 @@ fn main() {
593
  }
594
  }
595
 
596
- /// Simple timestamp without chrono dependency.
597
- fn chrono_lite() -> String {
598
- use std::time::SystemTime;
599
- let d = SystemTime::now()
600
- .duration_since(SystemTime::UNIX_EPOCH)
601
- .unwrap_or_default();
602
- let secs = d.as_secs();
603
- // Convert to roughly readable format (not perfect but unique)
604
- let s = secs % 60;
605
- let m = (secs / 60) % 60;
606
- let h = (secs / 3600) % 24;
607
- let days = secs / 86400;
608
- // Days since epoch → approximate date
609
- let (y, mo, day) = days_to_ymd(days);
610
- format!("{y:04}-{mo:02}-{day:02}_{h:02}-{m:02}-{s:02}")
611
- }
612
-
613
- fn days_to_ymd(mut days: u64) -> (u64, u64, u64) {
614
- // Rough Gregorian approximation
615
- let mut y = 1970;
616
- loop {
617
- let ydays = if y % 4 == 0 && (y % 100 != 0 || y % 400 == 0) { 366 } else { 365 };
618
- if days < ydays { break; }
619
- days -= ydays;
620
- y += 1;
621
- }
622
- let leap = y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
623
- let mdays = [31, if leap { 29 } else { 28 }, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
624
- let mut m = 0;
625
- while m < 12 && days >= mdays[m] {
626
- days -= mdays[m];
627
- m += 1;
628
- }
629
- (y, m as u64 + 1, days + 1)
630
  }
 
562
  });
563
 
564
  // Create run directory
565
+ let timestamp = timestamp();
566
  let run_dir = PathBuf::from(RUNS_DIR).join(&timestamp);
567
  let _ = fs::create_dir_all(&run_dir);
568
  let run_dir = strip_unc(fs::canonicalize(&run_dir).unwrap_or(run_dir));
 
593
  }
594
  }
595
 
596
+ fn timestamp() -> String {
597
+ chrono::Local::now().format("%Y-%m-%d_%H-%M-%S").to_string()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
598
  }