Skip to content

dtwallclock

Format wallclock durations into human-readable timestamps.

This group of functions provides timestamp formatting for wallclock-style durations. It is mainly for diagnostics, logging, and presentation paths that require fixed-width time strings. The formatting does not include localization.

Mini-guide

  • Formats integer microsecond or millisecond durations into fixed-width strings.
  • Uses 24-hour style hours without rollover handling beyond the provided duration.
  • Avoids dynamic allocation by relying entirely on caller-owned storage.

Example

char buf[32];
dterr_t* err;

err = dtwallclock_format_microseconds_as_hhmmss_llluuu(3723004005ULL, buf, sizeof(buf));
/* buf -> "01:02:03 004.005" */

err = dtwallclock_format_milliseconds_as_hhmmss_lll(3723004ULL, buf, sizeof(buf));
/* buf -> "01:02:03.004" */

Data structures

Functions

dtwallclock_format_microseconds_as_hhmmss_llluuu

Formats a microsecond duration into an HH:MM:SS mmm.uuu string.

Params:

uint64_t timestamp_micros Duration in microseconds to format.
char* buffer Destination buffer for the formatted string.
size_t buffer_size Size of the destination buffer in bytes.

Return: dterr_t* Error object when arguments are invalid, otherwise NULL.

dtwallclock_format_milliseconds_as_hhmmss_lll

Formats a millisecond duration into an HH:MM:SS.mmm string.

Params:

uint64_t timestamp_millis Duration in milliseconds to format.
char* buffer Destination buffer for the formatted string.
size_t buffer_size Size of the destination buffer in bytes.

Return: dterr_t* Error object when arguments are invalid, otherwise NULL.