Add "epoch" timestamp option

Add an option that prints the timestamp as the number of seconds since
the Unix epoch.
This commit is contained in:
Steve Marple 2024-08-23 12:11:05 +01:00 committed by Martin Lund
parent cdc773100c
commit f47467271f
6 changed files with 23 additions and 1 deletions

View file

@ -392,6 +392,10 @@ const char* option_timestamp_format_to_string(timestamp_t timestamp)
return "iso8601";
break;
case TIMESTAMP_EPOCH:
return "epoch";
break;
default:
return "unknown";
break;
@ -418,6 +422,10 @@ void option_parse_timestamp(const char *arg, timestamp_t *timestamp)
{
*timestamp = TIMESTAMP_ISO8601;
}
else if (strcmp(arg, "epoch") == 0)
{
*timestamp = TIMESTAMP_EPOCH;
}
else
{
tio_error_print("Invalid timestamp '%s'", arg);
@ -1151,7 +1159,7 @@ void options_parse_final(int argc, char *argv[])
if ( ((strncmp("COM", option.target, 3) == 0)
|| (strncmp("com", option.target, 3) == 0) )
&& (sscanf(option.target + 3, "%hhu", &portnum) == 1)
&& (portnum > 0) )
&& (portnum > 0) )
{
asprintf(&tty_win, "/dev/ttyS%hhu", portnum - 1);
option.target = tty_win;