Photon microGUI widgets library 0.6.0
ctime.hpp
1#ifndef _STDEX_CTIME_H
2#define _STDEX_CTIME_H
3
4#if _MSC_VER > 1000
5#pragma once
6#endif // _MSC_VER > 1000
7
8// stdex includes
9/*none*/
10
11// POSIX includes
12/*none*/
13
14// std includes
15#include <ctime>
16
17#if !defined(NULL)
18 #error "stdex:: non-conforming <ctime> header: no NULL"
19#endif
20
21#if !defined(CLOCKS_PER_SEC)
22 #error "stdex:: non-conforming <ctime> header: no CLOCKS_PER_SEC"
23#endif
24
25#if !defined(STDEX_NULL)
26 #define STDEX_NULL NULL
27#endif
28
29#if !defined(STDEX_CLOCKS_PER_SEC)
30 #define STDEX_CLOCKS_PER_SEC CLOCKS_PER_SEC
31#endif
32
33#if !defined(TIME_UTC)
34 #define TIME_UTC 1
35#endif
36
37#define STDEX_TIME_UTC TIME_UTC
38
39struct timespec;
40
41namespace stdex
42{
43 namespace ctime_cpp17
44 {
45#ifndef STDEX_DO_NOT_ADD_CPP17_STD // define to exclude std implementations
46 using namespace std;
47#endif
48 }
49
50 // Types
51 using std::clock_t;
52 using std::size_t;
53 using std::time_t;
54 using std::tm;
55
56 namespace detail
57 {
58 namespace ctime_detail
59 {
60 namespace std_dummy
61 {
62 using namespace std;
63
64 struct _dummy_2int
65 {
66 int _dummy[2];
67 };
68
69 _dummy_2int timespec_get(...);
70 }
71
72 namespace ctime_std_dummy
73 {
74 using namespace std_dummy;
75
76 struct _has_timespec
77 {
78 static const bool value =
79 sizeof(timespec_get(0, 0)) != sizeof(_dummy_2int);
80 };
81 }
82
83 using ctime_std_dummy::_has_timespec;
84 }
85
86 template<bool>
87 struct _timespec_impl
88 {
89 typedef ::timespec timespec;
90 };
91
92 template<>
93 struct _timespec_impl<false>
94 {
95 struct timespec
96 {
97 stdex::time_t tv_sec;
98 long tv_nsec;
99 };
100 };
101 }
102
103 typedef
104 detail::_timespec_impl<
105 detail::ctime_detail::_has_timespec::value>::timespec
106 timespec;
107
108 // Time manipulation
109 using std::clock;
110 using std::time;
111 using std::difftime;
112
113 namespace ctime_cpp17
114 {
115 int timespec_get(stdex::timespec* ts, int base); // C++ 17
116 }
117
118 using ctime_cpp17::timespec_get;
119
120 // Format conversions
121 using std::ctime;
122 using std::asctime;
123 using std::strftime;
124 //using std::wcsftime; // Defined in header <cwchar>
125 using std::gmtime;
126 using std::localtime;
127 using std::mktime;
128}
129
130#endif // _STDEX_CTIME_H