Skip to content

Commit

Permalink
Avoid unnecessary checked division
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Dec 1, 2023
1 parent f5d54cb commit f724e18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl FileTime {
/// let ft_i64 = FileTime::now().filetime();
/// ```
pub fn filetime(&self) -> i64 {
(self.secs * Self::HUNDREDS_OF_NANOSECONDS) + self.nsecs.checked_div(100).unwrap_or(0)
(self.secs * Self::HUNDREDS_OF_NANOSECONDS) + self.nsecs / 100
}

/// Return FILETIME epoch as DateTime<Utc>
Expand Down Expand Up @@ -115,7 +115,7 @@ impl FileTime {
pub fn from_datetime(dt: DateTime<Utc>) -> Self {
let nsecs = Self::EPOCH_AS_FILETIME
+ (dt.timestamp() * Self::HUNDREDS_OF_NANOSECONDS)
+ dt.timestamp_subsec_nanos().checked_div(100).unwrap_or(0) as i64;
+ (dt.timestamp_subsec_nanos() / 100) as i64;
Self::from_i64(nsecs)
}

Expand Down

0 comments on commit f724e18

Please sign in to comment.