Module timestamp_util

Utility functions for comparing timestamps.

Description

This module contains functions that are useful for comparing timestamps without running the risk of integer overflow.

Note that the functions in this module may be obsoleted in future versions of AtomVM, as support for arbitrary sized integers is added; however, the functions may still be useful in their own right.

Data Types

megasecs()


megasecs() = integer()

microsecs()


microsecs() = integer()

secs()


secs() = integer()

timestamp()


timestamp() = {megasecs(), secs(), microsecs()}

Function Index

delta/2 Computes the difference between TS2 and TS1, as a timestamp.
delta_ms/2 Computes the difference between TS2 and TS1, in milliseconds.

Function Details

delta/2


delta(TS2::timestamp(), TS1::timestamp()) -> timestamp()

TS2: a timestamp
TS1: a timestamp

returns: TS2 - TS1, as a timestamp

Computes the difference between TS2 and TS1, as a timestamp.

delta_ms/2


delta_ms(TS2::timestamp(), TS1::timestamp()) -> integer()

TS2: a timestamp
TS1: a timestamp

returns: TS2 - TS1, in milliseconds

Computes the difference between TS2 and TS1, in milliseconds.