Skip to content

Commit d117a7a

Browse files
committed
crc: remove system time utility functions, #5918
1 parent 24f7163 commit d117a7a

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

stacks-signer/src/signerdb.rs

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,48 +1567,6 @@ pub mod tests {
15671567
assert_eq!(BlockInfo::from(block_proposal_2), block_info);
15681568
}
15691569

1570-
fn system_time_from_ymd_hms_optional(
1571-
year: u32,
1572-
month: u32,
1573-
day: u32,
1574-
hour: u32,
1575-
minute: u32,
1576-
second: u32,
1577-
) -> Option<SystemTime> {
1578-
use std::time::{Duration, UNIX_EPOCH};
1579-
1580-
use chrono::NaiveDate;
1581-
// Make sure year is safe to cast
1582-
if year > i32::MAX as u32 {
1583-
return None;
1584-
}
1585-
// Cast year to i32 safely
1586-
let year_i32 = year as i32;
1587-
let naive =
1588-
NaiveDate::from_ymd_opt(year_i32, month, day)?.and_hms_opt(hour, minute, second)?;
1589-
1590-
let timestamp = naive.timestamp();
1591-
if timestamp < 0 {
1592-
return None;
1593-
}
1594-
1595-
// Convert to SystemTime
1596-
let duration = timestamp as u64;
1597-
Some(UNIX_EPOCH + Duration::from_secs(duration))
1598-
}
1599-
1600-
fn system_time_from_ymd_hms(
1601-
year: u32,
1602-
month: u32,
1603-
day: u32,
1604-
hour: u32,
1605-
minute: u32,
1606-
second: u32,
1607-
) -> SystemTime {
1608-
system_time_from_ymd_hms_optional(year, month, day, hour, minute, second)
1609-
.expect("Invalid system time")
1610-
}
1611-
16121570
#[test]
16131571
fn test_basic_signer_db() {
16141572
let db_path = tmp_db_path();
@@ -2581,7 +2539,7 @@ pub mod tests {
25812539
},
25822540
)
25832541
.unwrap();
2584-
let time_1 = system_time_from_ymd_hms(2025, 4, 17, 12, 30, 0);
2542+
let time_1 = SystemTime::UNIX_EPOCH;
25852543

25862544
let address_2 = StacksAddress::p2pkh(false, &StacksPublicKey::new());
25872545
let update_2 = StateMachineUpdate::new(
@@ -2594,7 +2552,7 @@ pub mod tests {
25942552
},
25952553
)
25962554
.unwrap();
2597-
let time_2 = system_time_from_ymd_hms(2025, 4, 17, 12, 30, 1);
2555+
let time_2 = SystemTime::UNIX_EPOCH + Duration::from_secs(1);
25982556

25992557
let address_3 = StacksAddress::p2pkh(false, &StacksPublicKey::new());
26002558
let update_3 = StateMachineUpdate::new(
@@ -2607,7 +2565,7 @@ pub mod tests {
26072565
},
26082566
)
26092567
.unwrap();
2610-
let time_3 = system_time_from_ymd_hms(2025, 4, 17, 12, 30, 10);
2568+
let time_3 = SystemTime::UNIX_EPOCH + Duration::from_secs(10);
26112569

26122570
assert_eq!(
26132571
0,

0 commit comments

Comments
 (0)