diff --git a/iox_time/src/lib.rs b/iox_time/src/lib.rs index 9cc1e5be03..d5de3dea58 100644 --- a/iox_time/src/lib.rs +++ b/iox_time/src/lib.rs @@ -82,14 +82,6 @@ impl Time { Self(Utc.timestamp_millis(millis)) } - /// Makes a new `DateTime` from the number of non-leap milliseconds - /// since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp"). - /// - /// Returns None if out of range - pub fn from_timestamp_millis_opt(millis: i64) -> Option { - Some(Self(Utc.timestamp_millis_opt(millis).single()?)) - } - /// Makes a new `Time` from the number of non-leap seconds /// since January 1, 1970 0:00:00 UTC (aka "UNIX timestamp") /// and the number of nanoseconds since the last whole non-leap second. @@ -324,8 +316,6 @@ mod test { assert!(chrono::Duration::from_std(duration).is_err()); assert!(time.checked_add(duration).is_none()); assert!(time.checked_sub(duration).is_none()); - - assert!(Time::from_timestamp_millis_opt(i64::MAX).is_none()) } #[test] diff --git a/write_buffer/src/kafka/mod.rs b/write_buffer/src/kafka/mod.rs index 6623e1f622..45d672d5d5 100644 --- a/write_buffer/src/kafka/mod.rs +++ b/write_buffer/src/kafka/mod.rs @@ -191,18 +191,10 @@ impl WriteBufferStreamHandler for RSKafkaStreamHandler { sequence_number: SequenceNumber::new(record.offset), }; - let timestamp_millis = - i64::try_from(record.record.timestamp.unix_timestamp_nanos() / 1_000_000) - .map_err(WriteBufferError::invalid_data)?; + let timestamp_nanos = i64::try_from(record.record.timestamp.unix_timestamp_nanos()) + .map_err(WriteBufferError::invalid_data)?; - let timestamp = Time::from_timestamp_millis_opt(timestamp_millis) - .ok_or_else::(|| { - format!( - "Cannot parse timestamp for milliseconds: {}", - timestamp_millis - ) - .into() - })?; + let timestamp = Time::from_timestamp_nanos(timestamp_nanos); let value = record .record