2 * msvcrt.dll date/time functions
4 * Copyright 1996,1998 Marcus Meissner
5 * Copyright 1996 Jukka Iivonen
6 * Copyright 1997,2000 Uwe Bonnes
7 * Copyright 2000 Jon Griffiths
11 #include <sys/times.h>
14 #include "msvcrt/sys/timeb.h"
15 #include "msvcrt/time.h"
18 DEFAULT_DEBUG_CHANNEL(msvcrt);
21 /* INTERNAL: Return formatted current time/date */
22 char* msvcrt_get_current_time(char* out, const char* format)
24 static const MSVCRT_time_t bad_time = (MSVCRT_time_t)-1;
26 struct tm *_tm = NULL;
29 if (time(&t) != bad_time && (_tm = localtime(&t)) &&
30 strftime(out,9,format,_tm) == 8)
35 /**********************************************************************
38 char* _strdate(char* date)
40 return msvcrt_get_current_time(date,"%m/%d/%y");
43 /*********************************************************************
46 char* _strtime(char* date)
48 return msvcrt_get_current_time(date,"%H:%M:%S");
51 /*********************************************************************
54 MSVCRT_clock_t MSVCRT_clock(void)
60 res = alltimes.tms_utime + alltimes.tms_stime +
61 alltimes.tms_cutime + alltimes.tms_cstime;
62 /* FIXME: We need some symbolic representation for CLOCKS_PER_SEC,
63 * 10 holds only for Windows/Linux_i86)
68 /*********************************************************************
71 double MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2)
73 return (double)(time1 - time2);
76 /*********************************************************************
79 MSVCRT_time_t MSVCRT_time(MSVCRT_time_t* buf)
81 MSVCRT_time_t curtime = time(NULL);
82 return buf ? *buf = curtime : curtime;
85 /*********************************************************************
88 void _ftime(struct _timeb *buf)
90 buf->time = MSVCRT_time(NULL);
91 buf->millitm = 0; /* FIXME */