Slightly improve keyboard tracking in combobox.
[wine/testsucceed.git] / dlls / msvcrt / time.c
blobc2f3d573259868a1ab49fb576f122edaf68f3c83
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 #include "msvcrt/stdlib.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;
25 time_t t;
26 struct tm *_tm = NULL;
27 char *retval = NULL;
29 if (time(&t) != bad_time && (_tm = localtime(&t)) &&
30 strftime(out,9,format,_tm) == 8)
31 retval = out;
32 if (_tm)
33 MSVCRT_free(_tm);
34 return retval;
37 /**********************************************************************
38 * _strdate (MSVCRT.@)
40 char* _strdate(char* date)
42 return msvcrt_get_current_time(date,"%m/%d/%y");
45 /*********************************************************************
46 * _strtime (MSVCRT.@)
48 char* _strtime(char* date)
50 return msvcrt_get_current_time(date,"%H:%M:%S");
53 /*********************************************************************
54 * clock (MSVCRT.@)
56 MSVCRT_clock_t MSVCRT_clock(void)
58 struct tms alltimes;
59 clock_t res;
61 times(&alltimes);
62 res = alltimes.tms_utime + alltimes.tms_stime +
63 alltimes.tms_cutime + alltimes.tms_cstime;
64 /* FIXME: We need some symbolic representation for CLOCKS_PER_SEC,
65 * 10 holds only for Windows/Linux_i86)
67 return 10*res;
70 /*********************************************************************
71 * difftime (MSVCRT.@)
73 double MSVCRT_difftime(MSVCRT_time_t time1, MSVCRT_time_t time2)
75 return (double)(time1 - time2);
78 /*********************************************************************
79 * time (MSVCRT.@)
81 MSVCRT_time_t MSVCRT_time(MSVCRT_time_t* buf)
83 MSVCRT_time_t curtime = time(NULL);
84 return buf ? *buf = curtime : curtime;
87 /*********************************************************************
88 * _ftime (MSVCRT.@)
90 void _ftime(struct _timeb *buf)
92 buf->time = MSVCRT_time(NULL);
93 buf->millitm = 0; /* FIXME */
94 buf->timezone = 0;
95 buf->dstflag = 0;