diff --git a/include/project.h b/include/project.h index 64ac42d..a376357 100644 --- a/include/project.h +++ b/include/project.h @@ -2,6 +2,7 @@ #ifndef _PROJECT_H #define _PROJECT_H +#include #include #include "macros.h" @@ -24,7 +25,7 @@ /// Project license #define PROG_LICENSE _PROJECT_LICENSE /// Compiled time (UTC unix timestamp) -#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, u64) +#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, time_t) // Returns from the program diff --git a/src/main.c b/src/main.c index 0e1682a..a392e8e 100644 --- a/src/main.c +++ b/src/main.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -15,6 +16,21 @@ #include #include +static const char* _compdate_readable() +{ + static const time_t comp = PROG_COMPILED_TIMESTAMP; + + static _Thread_local char date[40] = {0}; + debug_assert(sizeof(date) == 40); + + struct tm* time = gmtime(&comp); + if(!date[0]) { + usize w = strftime(date, sizeof(date), "%Y-%m-%d %H:%M:%S", time); + TRACE("size of hr time: %lu / %lu", w, sizeof(date)); + } + return date; +} + static void pi_print_trace_infos(FILE* out) { const char* name; @@ -42,10 +58,19 @@ void prog_info(FILE* out) #ifdef DEBUG " (debug build)" #endif - "\n written by %s with <3 (compiled at %lu UTC (unix ts))\n license %s.\n", + "\n written by %s with <3 (compiled at %s UTC." +#ifdef DEBUG + " %lu uts)" +#else + ")" +#endif + "\n license %s.\n", v_ctoss(v_rawtoc(PROG_VERSION)), PROG_AUTHOUR, + _compdate_readable(), +#ifdef DEBUG PROG_COMPILED_TIMESTAMP, +#endif PROG_LICENSE); fprintf(out, "\nLogging levels: (set with env-var `%s')\n", _TRACE_CONTROL_ENV_NAME); pi_print_trace_infos(out);