Adjust the 'MSVCRT_' prefix to match the msvcrt headers
[wine.git] / dlls / msvcrt / time.c
blobfbb1eb8b06a7d8526fc24436a32eb3134c2a5683
1 /*
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
8 */
9 #include <time.h>
10 #include <sys/times.h>
11 #include "msvcrt.h"
13 DEFAULT_DEBUG_CHANNEL(msvcrt);
15 typedef struct __MSVCRT_timeb
17 time_t time;
18 unsigned short millitm;
19 short timezone;
20 short dstflag;
21 } MSVCRT_timeb;
24 /* INTERNAL: Return formatted current time/date */
25 char* msvcrt_get_current_time(char* out, const char* format)
27 static const time_t bad_time = (time_t)-1;
28 time_t t;
29 struct tm *_tm = NULL;
30 char *retval = NULL;
32 if (time(&t) != bad_time && (_tm = localtime(&t)) &&
33 strftime(out,9,format,_tm) == 8)
34 retval = out;
35 if (_tm)
36 MSVCRT_free(_tm);
37 return retval;
40 /**********************************************************************
41 * _strdate (MSVCRT.@)
43 char* _strdate(char* date)
45 return msvcrt_get_current_time(date,"%m/%d/%y");
48 /*********************************************************************
49 * _strtime (MSVCRT.@)
51 char* _strtime(char* date)
53 return msvcrt_get_current_time(date,"%H:%M:%S");
56 /*********************************************************************
57 * clock (MSVCRT.@)
59 clock_t MSVCRT_clock(void)
61 struct tms alltimes;
62 clock_t res;
64 times(&alltimes);
65 res = alltimes.tms_utime + alltimes.tms_stime +
66 alltimes.tms_cutime + alltimes.tms_cstime;
67 /* FIXME: We need some symbolic representation for CLOCKS_PER_SEC,
68 * 10 holds only for Windows/Linux_i86)
70 return 10*res;
73 /*********************************************************************
74 * difftime (MSVCRT.@)
76 double MSVCRT_difftime(time_t time1, time_t time2)
78 return (double)(time1 - time2);
81 /*********************************************************************
82 * time (MSVCRT.@)
84 time_t MSVCRT_time(time_t* buf)
86 time_t curtime = time(NULL);
87 return buf ? *buf = curtime : curtime;
90 /*********************************************************************
91 * _ftime (MSVCRT.@)
93 void _ftime(MSVCRT_timeb* buf)
95 buf->time = MSVCRT_time(NULL);
96 buf->millitm = 0; /* FIXME */
97 buf->timezone = 0;
98 buf->dstflag = 0;