X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=569526af608cf081e8dd976e5e8d581f91567d8e;hp=d3ce694021fc36fe30e04b263406622ff0c2ad0e;hb=dfe5aa4b462c9507926f1c7a1b8c30911bfacef1;hpb=d239aab42a5a0661af0056f7f01e95a7f05bd757 diff --git a/src/libgame/misc.c b/src/libgame/misc.c index d3ce6940..569526af 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -918,6 +918,23 @@ char *getDefaultUserName(int nr) return user_name[nr]; } +char *getTimestampFromEpoch(time_t epoch_seconds) +{ + struct tm *now = localtime(&epoch_seconds); + static char timestamp[20]; + + sprintf(timestamp, "%04d%02d%02d-%02d%02d%02d", + now->tm_year + 1900, now->tm_mon + 1, now->tm_mday, + now->tm_hour, now->tm_min, now->tm_sec); + + return timestamp; +} + +char *getCurrentTimestamp(void) +{ + return getTimestampFromEpoch(time(NULL)); +} + time_t getFileTimestampEpochSeconds(char *filename) { struct stat file_status;