]> git.saurik.com Git - wxWidgets.git/blob - include/wx/time.h
Extract PipeIOHandler class into a header and rename to wxWakeUpPipe.
[wxWidgets.git] / include / wx / time.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/time.h
3 // Purpose: Miscellaneous time-related functions.
4 // Author: Vadim Zeitlin
5 // Created: 2011-11-26
6 // RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_TIME_H_
12 #define _WX_TIME_H_
13
14 #include "wx/longlong.h"
15
16 // Returns the difference between UTC and local time in seconds.
17 WXDLLIMPEXP_BASE int wxGetTimeZone();
18
19 // Get number of seconds since local time 00:00:00 Jan 1st 1970.
20 extern long WXDLLIMPEXP_BASE wxGetLocalTime();
21
22 // Get number of seconds since GMT 00:00:00, Jan 1st 1970.
23 extern long WXDLLIMPEXP_BASE wxGetUTCTime();
24
25 #if wxUSE_LONGLONG
26 typedef wxLongLong wxMilliClock_t;
27 inline long wxMilliClockToLong(wxLongLong ll) { return ll.ToLong(); }
28 #else
29 typedef double wxMilliClock_t;
30 inline long wxMilliClockToLong(double d) { return wx_truncate_cast(long, d); }
31 #endif // wxUSE_LONGLONG
32
33 // Get number of milliseconds since local time 00:00:00 Jan 1st 1970
34 extern wxMilliClock_t WXDLLIMPEXP_BASE wxGetLocalTimeMillis();
35
36 #if wxUSE_LONGLONG
37
38 // Get the number of milliseconds or microseconds since the Epoch.
39 wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeMillis();
40 wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeUSec();
41
42 #endif // wxUSE_LONGLONG
43
44 #define wxGetCurrentTime() wxGetLocalTime()
45
46 // on some really old systems gettimeofday() doesn't have the second argument,
47 // define wxGetTimeOfDay() to hide this difference
48 #ifdef HAVE_GETTIMEOFDAY
49 #ifdef WX_GETTIMEOFDAY_NO_TZ
50 #define wxGetTimeOfDay(tv) gettimeofday(tv)
51 #else
52 #define wxGetTimeOfDay(tv) gettimeofday((tv), NULL)
53 #endif
54 #endif // HAVE_GETTIMEOFDAY
55
56 /* Two wrapper functions for thread safety */
57 #ifdef HAVE_LOCALTIME_R
58 #define wxLocaltime_r localtime_r
59 #else
60 WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*);
61 #if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
62 // On Windows, localtime _is_ threadsafe!
63 #warning using pseudo thread-safe wrapper for localtime to emulate localtime_r
64 #endif
65 #endif
66
67 #ifdef HAVE_GMTIME_R
68 #define wxGmtime_r gmtime_r
69 #else
70 WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*);
71 #if wxUSE_THREADS && !defined(__WINDOWS__) && !defined(__WATCOMC__)
72 // On Windows, gmtime _is_ threadsafe!
73 #warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r
74 #endif
75 #endif
76
77 #endif // _WX_TIME_H_