From 481c9c4e8d30ad672c3dfb889820e31942c3f02b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 20 Nov 2003 07:00:07 +0000 Subject: [PATCH] add Sys_TimeOfDay from QWE (HighlandeR) --- include/QF/sys.h | 11 +++++++++++ libs/util/sys.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/QF/sys.h b/include/QF/sys.h index 1ba136bce..abf3d5c25 100644 --- a/include/QF/sys.h +++ b/include/QF/sys.h @@ -48,6 +48,16 @@ enum e_pathtype { PATHTYPE_RELATIVE_BELOW }; +typedef struct date_s { + int sec; + int min; + int hour; + int day; + int mon; + int year; + char str[128]; +} date_t; + int Sys_FileTime (const char *path); void Sys_mkdir (const char *path); enum e_pathtype Sys_PathType (const char *path); @@ -65,6 +75,7 @@ void Sys_Quit (void) __attribute__((noreturn)); void Sys_Shutdown (void); void Sys_RegisterShutdown (void (*func) (void)); double Sys_DoubleTime (void); +void Sys_TimeOfDay(date_t *date); int Sys_CheckInput (int idle, int net_socket); const char *Sys_ConsoleInput (void); diff --git a/libs/util/sys.c b/libs/util/sys.c index 5be786f4d..ac40bfa54 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -325,6 +325,24 @@ Sys_DoubleTime (void) #endif } +void +Sys_TimeOfDay (date_t *date) +{ + struct tm *newtime; + time_t long_time; + + time (&long_time); + newtime = localtime (&long_time); + + date->day = newtime->tm_mday; + date->mon = newtime->tm_mon; + date->year = newtime->tm_year + 1900; + date->hour = newtime->tm_hour; + date->min = newtime->tm_min; + date->sec = newtime->tm_sec; + strftime (date->str, 128, "%a %b %d, %H:%M %Y", newtime); +} + void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length) {