Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions edn/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ pub trait FromMicros {

impl FromMicros for DateTime<UTC> {
fn from_micros(ts: i64) -> Self {
UTC.timestamp(ts / 100_000, ((ts % 100_000).abs() as u32) * 1_000)
UTC.timestamp(ts / 1_000_000, ((ts % 1_000_000).abs() as u32) * 1_000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth defining a constant for 1_000_000 that we can use here so if we need to implement FromMicros for another type we are less likely to make the same mistake?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not — my reasoning is: we're likely to wrap DateTime rather than directly implement FromMicros, and if we do do it again we'll probably forget to use the constant!

hashtag-realism hashtag-bugs

}
}

Expand All @@ -573,7 +573,9 @@ pub trait ToMicros {

impl ToMicros for DateTime<UTC> {
fn to_micros(&self) -> i64 {
(self.timestamp() * 100_000) + (self.timestamp_subsec_micros() as i64)
let major: i64 = self.timestamp() * 1_000_000;
let minor: i64 = self.timestamp_subsec_micros() as i64;
major + minor
}
}

Expand Down