1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2003, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
22 ***************************************************************************/
29 #ifndef HAVE_GETTIMEOFDAY
33 gettimeofday (struct timeval *tp, void *nothing)
39 /* mktime converts local to UTC */
41 tmtm.tm_sec = st.wSecond;
42 tmtm.tm_min = st.wMinute;
43 tmtm.tm_hour = st.wHour;
44 tmtm.tm_mday = st.wDay;
45 tmtm.tm_mon = st.wMonth - 1;
46 tmtm.tm_year = st.wYear - 1900;
50 tp->tv_usec = st.wMilliseconds * 1000;
53 ** The earlier time calculations using GetLocalTime
54 ** had a time resolution of 10ms.The timeGetTime, part
55 ** of multimedia apis offer a better time resolution
56 ** of 1ms.Need to link against winmm.lib for this
58 unsigned long Ticks = 0;
60 unsigned long Usec = 0;
61 Ticks = timeGetTime();
64 Usec = (Ticks - (Sec*1000))*1000;
70 #define HAVE_GETTIMEOFDAY
74 struct timeval Curl_tvnow (void)
77 #ifdef HAVE_GETTIMEOFDAY
78 gettimeofday (&now, NULL);
80 now.tv_sec = (long) time(NULL);
87 * Make sure that the first argument is the more recent time, as otherwise
88 * we'll get a weird negative time-diff back...
90 long Curl_tvdiff (struct timeval newer, struct timeval older)
92 return (newer.tv_sec-older.tv_sec)*1000+
93 (499+newer.tv_usec-older.tv_usec)/1000;
96 long Curl_tvlong (struct timeval t1)
103 * eval: (load-file "../curl-mode.el")
106 * vim: et sw=2 ts=2 sts=2 tw=78