Skip to content
/ osd Public

Commit 82e2a43

Browse files
committed
Adding a $tu specifier to distinguish UTC time and local time printing, saving the time format
1 parent 5a997ec commit 82e2a43

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/app_config.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ int save_app_config(void) {
5555
fprintf(file, " web_auth_pass: %s\n", app_config.web_auth_pass);
5656
fprintf(file, " web_enable_static: %s\n", app_config.web_enable_static ? "true" : "false");
5757
fprintf(file, " web_server_thread_stack_size: %d\n", app_config.web_server_thread_stack_size);
58+
if (!EMPTY(timefmt) || EQUALS(timefmt, DEF_TIMEFMT))
59+
fprintf(file, " time_format: %s\n", timefmt);
5860

5961
for (char i = 0; i < MAX_OSD; i++) {
6062
char imgEmpty = EMPTY(osds[i].img);
@@ -124,6 +126,9 @@ enum ConfigError parse_app_config(void) {
124126
&app_config.web_server_thread_stack_size);
125127
if (err != CONFIG_OK)
126128
goto RET_ERR;
129+
parse_param_value(&ini, "system", "time_format", timefmt);
130+
if (EMPTY(timefmt))
131+
strcpy(timefmt, DEF_TIMEFMT);
127132

128133
for (char i = 0; i < MAX_OSD; i++) {
129134
char param[8];

src/region.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
osd osds[MAX_OSD];
44
pthread_t regionPid = 0;
5-
char timefmt[32] = DEF_TIMEFMT;
5+
char timefmt[64];
66
unsigned int rxb_l, txb_l, cpu_l[6];
77

88
void region_fill_formatted(char* str) {
@@ -109,7 +109,11 @@ void region_fill_formatted(char* str) {
109109
ipos++;
110110
char s[64];
111111
time_t t = time(NULL);
112-
struct tm *tm = gmtime(&t);
112+
struct tm *tm;
113+
if (str[ipos + 1] == 'u') {
114+
ipos++;
115+
tm = gmtime(&t);
116+
} else tm = localtime(&t);
113117
strftime(s, 64, timefmt, tm);
114118
strcat(out, s);
115119
opos += strlen(s);

src/region.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ typedef struct {
6868
} osd;
6969

7070
extern osd osds[MAX_OSD];
71-
extern char timefmt[32];
71+
extern char timefmt[64];
7272

7373
int start_region_handler();
7474
void stop_region_handler();

0 commit comments

Comments
 (0)