pub(crate) fn rotation_window(timestamp_unix_ns: i64, rotate_secs: u64) -> i64Expand description
Returns the index of the aligned rotation window holding a timestamp.
Windows start at multiples of rotate_secs since the Unix epoch, so with a
five-minute period every file covers :00-:05, :05-:10 and so on. Floor division is
used, so timestamps before the epoch get negative indices.
§Arguments
timestamp_unix_ns- Sample time in Unix nanoseconds.rotate_secs- Window length in seconds.0is treated as1.
§Returns
The number of whole windows between the Unix epoch and the timestamp.
§Examples
rotation_window(299_999_999_999, 300) == 0
rotation_window(300_000_000_000, 300) == 1
rotation_window(-1, 300) == -1