File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,17 @@ impl SlotCalculator {
234234 self . point_within_slot ( chrono:: Utc :: now ( ) . timestamp ( ) as u64 )
235235 }
236236
237+ /// The current number of milliseconds into the slot.
238+ pub fn current_point_within_slot_ms ( & self ) -> Option < u64 > {
239+ let now = chrono:: Utc :: now ( ) ;
240+ let timestamp = now. timestamp ( ) as u64 ;
241+ let millis = now. timestamp_subsec_millis ( ) as u64 ;
242+
243+ self . point_within_slot ( timestamp) . map ( |point| {
244+ std:: time:: Duration :: from_secs ( point) . as_millis ( ) as u64 + millis
245+ } )
246+ }
247+
237248 /// Calculates the slot that starts at the given timestamp.
238249 /// Returns `None` if the timestamp is not a slot boundary.
239250 /// Returns `None` if the timestamp is before the chain's start timestamp.
You can’t perform that action at this time.
0 commit comments