macula_time (macula v0.20.5)

View Source

Time utilities for Macula. Provides functions for timestamps, durations, and timeouts.

Summary

Functions

Calculate duration in milliseconds between two timestamps.

Format duration in milliseconds to human-readable string.

Format timestamp to ISO 8601 string.

Check if timeout has expired.

Convert minutes to milliseconds.

Convert milliseconds to seconds (truncates).

Convert seconds to milliseconds.

Calculate remaining time before timeout (in milliseconds). Returns 0 if already expired.

Get current timestamp in milliseconds since epoch.

Get current timestamp in microseconds since epoch.

Functions

duration_ms(StartTimestamp, EndTimestamp)

-spec duration_ms(integer(), integer()) -> non_neg_integer().

Calculate duration in milliseconds between two timestamps.

format_duration_ms(Ms)

-spec format_duration_ms(non_neg_integer()) -> binary().

Format duration in milliseconds to human-readable string.

format_timestamp(TimestampMs)

-spec format_timestamp(integer()) -> binary().

Format timestamp to ISO 8601 string.

is_expired(StartTimestamp, TimeoutMs)

-spec is_expired(integer(), pos_integer()) -> boolean().

Check if timeout has expired.

minutes_to_ms(Minutes)

-spec minutes_to_ms(non_neg_integer()) -> non_neg_integer().

Convert minutes to milliseconds.

ms_to_seconds(Ms)

-spec ms_to_seconds(non_neg_integer()) -> non_neg_integer().

Convert milliseconds to seconds (truncates).

seconds_to_ms(Seconds)

-spec seconds_to_ms(non_neg_integer()) -> non_neg_integer().

Convert seconds to milliseconds.

time_remaining(StartTimestamp, TimeoutMs)

-spec time_remaining(integer(), pos_integer()) -> non_neg_integer().

Calculate remaining time before timeout (in milliseconds). Returns 0 if already expired.

timestamp()

-spec timestamp() -> integer().

Get current timestamp in milliseconds since epoch.

timestamp_microseconds()

-spec timestamp_microseconds() -> integer().

Get current timestamp in microseconds since epoch.