Skip to content

Commit

Permalink
Fix last_enqueued_time_utc on Linux and other platforms that can repr…
Browse files Browse the repository at this point in the history
…esent 1-1-0001 as a SystemTime (but not as an OffsetDateTime). (#2180)

* Fixed #2128

* Removed traces
  • Loading branch information
LarryOsterman authored Feb 14, 2025
1 parent b6a1e49 commit 68f7fc8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk/core/azure_core_amqp/src/fe2o3/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ const CE_ZERO_MILLISECONDS: i64 = -62_135_596_800_000;

impl From<fe2o3_amqp_types::primitives::Timestamp> for AmqpTimestamp {
fn from(timestamp: fe2o3_amqp_types::primitives::Timestamp) -> Self {
// The AMQP timestamp is the number of milliseconds since the Unix epoch.
// AMQP brokers represent the lowest value as -62_135_596_800_000 (the
// number of milliseconds between the Unix epoch (1/1/1970) and year 1 CE) as
// a sentinel for a time which is not set.
if (timestamp.milliseconds() as u64) == CE_ZERO_MILLISECONDS as u64 {
return AmqpTimestamp(None);
}
AmqpTimestamp(
std::time::UNIX_EPOCH.checked_add(std::time::Duration::from_millis(
timestamp.milliseconds() as u64,
Expand Down

0 comments on commit 68f7fc8

Please sign in to comment.