Skip to content

Conversation

@dylanlott
Copy link
Contributor

@dylanlott dylanlott commented Nov 24, 2025

feat: adds support for millisecond slot timepoints

Copy link
Contributor Author

dylanlott commented Nov 24, 2025

/// The current number of milliseconds into the slot.
pub fn current_point_within_slot_ms(&self) -> Option<u64> {
let now = chrono::Utc::now();
let timestamp = now.timestamp() as u64;
Copy link
Member

Choose a reason for hiding this comment

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

let millis = now.timestamp_subsec_millis() as u64;

self.point_within_slot(timestamp)
.map(|point| std::time::Duration::from_secs(point).as_millis() as u64 + millis)
Copy link
Member

Choose a reason for hiding this comment

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

rather than operating on seconds, and then converting to ms and adding, just do math on the u64s

add

fn point_within_slot_ms
fn slot_utc_offset_ms

etc.

do not concert to Duration as that may mess up the math

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants