Skip to content

Commit

Permalink
time: Add WallClockTime dumper function for debugging purposes
Browse files Browse the repository at this point in the history
Signed-off-by: shifter <[email protected]>
  • Loading branch information
bshifter committed Jan 24, 2025
1 parent 122ea49 commit b41e1eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/timeutils/wallclocktime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,3 +1005,25 @@ find_string(const unsigned char *bp, int *tgt, const char *const *n1,
/* Nothing matched */
return NULL;
}

void
dump_wall_clock_time(const WallClockTime *wct, GString *output)
{
if (!wct || !output)
return;

g_string_append_printf(output, "WallClockTime:\n");
g_string_append_printf(output, " Year: %d\n", wct->wct_year + 1900); // tm_year is years since 1900
g_string_append_printf(output, " Month: %d\n", wct->wct_mon + 1); // tm_mon is zero-based
g_string_append_printf(output, " Day of Month: %d\n", wct->wct_mday);
g_string_append_printf(output, " Weekday: %d\n", wct->wct_wday);
g_string_append_printf(output, " Day of Year: %d\n", wct->wct_yday);
g_string_append_printf(output, " Hour: %d\n", wct->wct_hour);
g_string_append_printf(output, " Minute: %d\n", wct->wct_min);
g_string_append_printf(output, " Second: %d\n", wct->wct_sec);
g_string_append_printf(output, " Microsecond: %d\n", wct->wct_usec);
g_string_append_printf(output, " DST: %d\n", wct->wct_isdst);

g_string_append_printf(output, " GMT Offset: %ld\n", wct->wct_gmtoff);
g_string_append_printf(output, " Timezone: %s\n", wct->wct_zone ? wct->wct_zone : "(null)");
}
1 change: 1 addition & 0 deletions lib/timeutils/wallclocktime.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,6 @@ void wall_clock_time_unset(WallClockTime *wct);
gchar *wall_clock_time_strptime(WallClockTime *wct, const gchar *format, const gchar *input);
void wall_clock_time_guess_missing_year(WallClockTime *self);
void wall_clock_time_guess_missing_fields(WallClockTime *self);
void dump_wall_clock_time(const WallClockTime *wct, GString *output);

#endif

0 comments on commit b41e1eb

Please sign in to comment.