From 9bb8107e897c9fb37b6d42d898461d27c0e47ed8 Mon Sep 17 00:00:00 2001 From: Elliana May Date: Sat, 13 Apr 2024 21:55:09 +0800 Subject: [PATCH] chore: name magic number --- src/types/chrono.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/types/chrono.rs b/src/types/chrono.rs index 3df17312..fecce4bb 100644 --- a/src/types/chrono.rs +++ b/src/types/chrono.rs @@ -134,7 +134,7 @@ impl FromSql for Duration { match value { ValueRef::Interval { months, days, nanos } => { let days = days + (months * 30); - let (additional_seconds, nanos) = nanos.div_mod_floor(&1_000_000_000); + let (additional_seconds, nanos) = nanos.div_mod_floor(&NANOS_PER_SECOND); let seconds = additional_seconds + (i64::from(days) * 24 * 3600); match nanos.try_into() { @@ -155,7 +155,8 @@ impl FromSql for Duration { const DAYS_PER_MONTH: i64 = 30; const SECONDS_PER_DAY: i64 = 24 * 3600; -const NANOS_PER_DAY: i64 = SECONDS_PER_DAY * 1_000_000_000; +const NANOS_PER_SECOND: i64 = 1_000_000_000; +const NANOS_PER_DAY: i64 = SECONDS_PER_DAY * NANOS_PER_SECOND; impl ToSql for Duration { fn to_sql(&self) -> Result> {