From 82a80c9d967dcf880ecd215c532c1fe7a5542aa0 Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 20 Nov 2023 20:10:55 +0330 Subject: [PATCH] Replace number with constant variable --- src/naive/datetime/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/naive/datetime/mod.rs b/src/naive/datetime/mod.rs index d678148ada..d127a3676f 100644 --- a/src/naive/datetime/mod.rs +++ b/src/naive/datetime/mod.rs @@ -13,7 +13,7 @@ use core::{fmt, str}; #[cfg(feature = "rkyv")] use rkyv::{Archive, Deserialize, Serialize}; -use crate::duration::Duration as OldDuration; +use crate::duration::{Duration as OldDuration, NANOS_PER_SEC}; #[cfg(feature = "alloc")] use crate::format::DelayedFormat; use crate::format::{parse, parse_and_remainder, ParseError, ParseResult, Parsed, StrftimeItems}; @@ -224,8 +224,8 @@ impl NaiveDateTime { #[inline] #[must_use] pub const fn from_timestamp_nanos(nanos: i64) -> Option { - let secs = nanos.div_euclid(1_000_000_000); - let nsecs = nanos.rem_euclid(1_000_000_000) as u32; + let secs = nanos.div_euclid(NANOS_PER_SEC as i64); + let nsecs = nanos.rem_euclid(NANOS_PER_SEC as i64) as u32; NaiveDateTime::from_timestamp_opt(secs, nsecs) }