added pretty_print_date_time function

This commit is contained in:
2023-08-23 20:03:26 +02:00
parent 8f1e0e7b1d
commit 0294dbf3e9
4 changed files with 21 additions and 4 deletions

View File

@ -1,4 +1,5 @@
#include "date_time_handling.h"
#include <stdio.h>
#include <time.h>
#include <string.h>
@ -10,3 +11,16 @@ void get_date(char buffer[]) {
strftime(buffer, buffer_size, "%Y%m%dT%H%M%S", my_tm_local);
}
// 20230823T194138 -> 2023-08-23 19:41:38
void pretty_print_date_time(char date_time[]) {
char *date = strtok(date_time, "T");
char *time = strtok(NULL, "T");
printf ("%c%c%c%c-", date[0], date[1], date[2], date[3]);
printf ("%c%c-", date[4], date[5]);
printf ("%c%c", date[6], date[7]);
if (time != NULL) {
printf (" %c%c:", time[0], time[1]);
printf ("%c%c:", time[2], time[3]);
printf ("%c%c", time[4], time[5]);
}
}