libobs/util: Add %s string replacement for unix time

Adds %s which replaces the keyword with the current unix epoch time.

The %s keyword is common in languages like PHP and Python, and even
some C implementations, but it is not standard so this is a fallback.
This commit is contained in:
tt2468
2022-05-28 18:30:41 -04:00
committed by Ryan Foster
parent 8e2e1e212c
commit f6a77ec0a6
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -19,6 +19,7 @@
#include <time.h>
#include <errno.h>
#include <stdlib.h>
#include <inttypes.h>
#include <locale.h>
#include "c99defs.h"
#include "platform.h"
@@ -782,6 +783,10 @@ char *os_generate_formatted_filename(const char *extension, bool space,
strcpy(convert, get_video_format_name(
ovi.output_format));
replace_text(&sf, pos, 3, convert);
} else if (astrcmp_n(cmp, "%s", 2) == 0) {
sprintf(convert, "%" PRId64, (int64_t)now);
replace_text(&sf, pos, 2, convert);
}
}