Coverage Report

Created: 2025-06-13 06:30

/src/wxwidgets/include/wx/time.h
Line
Count
Source (jump to first uncovered line)
1
///////////////////////////////////////////////////////////////////////////////
2
// Name:        wx/time.h
3
// Purpose:     Miscellaneous time-related functions.
4
// Author:      Vadim Zeitlin
5
// Created:     2011-11-26
6
// Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7
// Licence:     wxWindows licence
8
///////////////////////////////////////////////////////////////////////////////
9
10
#ifndef _WX_TIME_H_
11
#define _WX_TIME_H_
12
13
#include "wx/longlong.h"
14
15
// Returns the difference between UTC and local time in seconds.
16
WXDLLIMPEXP_BASE int wxGetTimeZone();
17
18
// Get number of seconds since local time 00:00:00 Jan 1st 1970.
19
extern long WXDLLIMPEXP_BASE wxGetLocalTime();
20
21
// Get number of seconds since GMT 00:00:00, Jan 1st 1970.
22
extern long WXDLLIMPEXP_BASE wxGetUTCTime();
23
24
typedef wxLongLong wxMilliClock_t;
25
0
inline long wxMilliClockToLong(wxLongLong ll) { return ll.ToLong(); }
26
27
// Get number of milliseconds since local time 00:00:00 Jan 1st 1970
28
extern wxMilliClock_t WXDLLIMPEXP_BASE wxGetLocalTimeMillis();
29
30
// Get the number of milliseconds or microseconds since the Epoch.
31
wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeMillis();
32
wxLongLong WXDLLIMPEXP_BASE wxGetUTCTimeUSec();
33
34
#define wxGetCurrentTime() wxGetLocalTime()
35
36
// on some really old systems gettimeofday() doesn't have the second argument,
37
// define wxGetTimeOfDay() to hide this difference
38
#ifdef HAVE_GETTIMEOFDAY
39
    #ifdef WX_GETTIMEOFDAY_NO_TZ
40
        #define wxGetTimeOfDay(tv)      gettimeofday(tv)
41
    #else
42
0
        #define wxGetTimeOfDay(tv)      gettimeofday((tv), nullptr)
43
    #endif
44
#endif // HAVE_GETTIMEOFDAY
45
46
/* Two wrapper functions for thread safety */
47
#ifdef HAVE_LOCALTIME_R
48
8.26k
#define wxLocaltime_r localtime_r
49
#else
50
WXDLLIMPEXP_BASE struct tm *wxLocaltime_r(const time_t*, struct tm*);
51
#if wxUSE_THREADS && !defined(__WINDOWS__)
52
     // On Windows, localtime _is_ threadsafe!
53
#warning using pseudo thread-safe wrapper for localtime to emulate localtime_r
54
#endif
55
#endif
56
57
#ifdef HAVE_GMTIME_R
58
0
#define wxGmtime_r gmtime_r
59
#else
60
WXDLLIMPEXP_BASE struct tm *wxGmtime_r(const time_t*, struct tm*);
61
#if wxUSE_THREADS && !defined(__WINDOWS__)
62
     // On Windows, gmtime _is_ threadsafe!
63
#warning using pseudo thread-safe wrapper for gmtime to emulate gmtime_r
64
#endif
65
#endif
66
67
#endif // _WX_TIME_H_