Skip to main content

Module time_codec

Module time_codec 

Source
Expand description

The original rwhod protocol uses 32-bit integers for timestamps, which will cause overflow issues after 2038-01-19. To mitigate this, we decode timestamps by looking at the time the packet was received, comparing it to the current time or the time the packet was received, and ensuring any overflowed timestamps are corrected accordingly.

Structsยง

RwhodTimestamps

Constantsยง

RWHOD_TIMESTAMP_CORRECTION_WINDOW ๐Ÿ”’
RWHOD_TIMESTAMP_FORWARD_ALLOWANCE ๐Ÿ”’
RWHOD_TIMESTAMP_WRAP_INCREMENT ๐Ÿ”’

Functionsยง

decode_rwhod_timestamp
Decodes a raw rwhod timestamp (i32) into a DateTime, adding a correction value to count for any detected overflows.
decode_rwhod_timestamp_near_time
Decodes a raw rwhod timestamp (i32) into a DateTime using the default wrap-sized interval around the reference time.
decode_rwhod_timestamp_near_time_with_forward_allowance
Decodes a raw rwhod timestamp (i32) into a DateTime using a wrap-sized interval around the provided time reference.
decode_rwhod_timestamps
encode_rwhod_timestamp
Encodes a DateTime into a raw rwhod timestamp (i32).
rwhod_time_correction
Calculates the correction value for a received rwhod timestamp (i32), based on the current time (now) and the received timestamp (recvtime).