AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
time.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 
4 #ifndef INCLUDED_OSL_TIME_H
5 #define INCLUDED_OSL_TIME_H
6 
7 #include "sal/config.h"
8 
9 #if defined LIBO_INTERNAL_ONLY
10 #if defined __cplusplus
11 #include <chrono>
12 #endif
13 #endif
14 
15 #include "sal/saldllapi.h"
16 #include "sal/types.h"
17 
18 #ifdef _WIN32
19 # pragma pack(push, 8)
20 #endif
21 
28 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
29 
30 struct TimeValue {
31  TimeValue() = default;
32 
33  constexpr TimeValue(sal_uInt32 seconds, sal_uInt32 nanoseconds):
34  Seconds(seconds), Nanosec(nanoseconds) {}
35 
36  template<typename Rep, typename Period> constexpr
37  TimeValue(std::chrono::duration<Rep, Period> const & duration):
38  Seconds(
39  std::chrono::duration_cast<std::chrono::nanoseconds>(
40  duration).count() / 1000000000),
41  Nanosec(
42  std::chrono::duration_cast<std::chrono::nanoseconds>(
43  duration).count() % 1000000000)
44  {}
45 
46  sal_uInt32 Seconds;
47  sal_uInt32 Nanosec;
48 };
49 
50 #else
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 typedef struct {
57  sal_uInt32 Seconds;
58  sal_uInt32 Nanosec;
59 } TimeValue;
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif
66 
67 #if defined(_WIN32)
68 # pragma pack(pop)
69 #endif
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
75 typedef struct _oslDateTime
76 {
79  sal_uInt32 NanoSeconds;
80 
83  sal_uInt16 Seconds;
84 
87  sal_uInt16 Minutes;
88 
91  sal_uInt16 Hours;
92 
95  sal_uInt16 Day;
96 
99  sal_uInt16 DayOfWeek;
100 
103  sal_uInt16 Month;
104 
107  sal_Int16 Year;
108 
109 } oslDateTime;
110 
111 
116  TimeValue* pTimeVal );
117 
118 
126  const TimeValue* pTimeVal, oslDateTime* pDateTime );
127 
128 
136  const oslDateTime* pDateTime, TimeValue* pTimeVal );
137 
138 
146  const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
147 
148 
156  const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
157 
158 
163 SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif // INCLUDED_OSL_TIME_H
170 
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Time since Jan-01-1970.
Definition: time.h:56
unsigned char sal_Bool
Definition: types.h:18
SAL_DLLPUBLIC sal_Bool osl_getSystemTime(TimeValue *pTimeVal)
Get the current system time as TimeValue.
sal_uInt16 Hours
contains the hour (0-23).
Definition: time.h:91
struct _oslDateTime oslDateTime
sal_uInt32 Seconds
Definition: time.h:57
Definition: time.h:75
SAL_DLLPUBLIC sal_Bool osl_getSystemTimeFromLocalTime(const TimeValue *pLocalTimeVal, TimeValue *pSystemTimeVal)
Convert local time to GMT.
sal_uInt32 NanoSeconds
contains the nanoseconds
Definition: time.h:79
sal_uInt16 Minutes
contains the minutes (0-59).
Definition: time.h:87
sal_Int16 Year
is the year.
Definition: time.h:107
sal_uInt32 Nanosec
Definition: time.h:58
sal_uInt16 DayOfWeek
is the day of week (0-6 , 0 : Sunday).
Definition: time.h:99
sal_uInt16 Month
is the month of year (1-12).
Definition: time.h:103
SAL_DLLPUBLIC sal_Bool osl_getDateTimeFromTimeValue(const TimeValue *pTimeVal, oslDateTime *pDateTime)
Get the GMT from a TimeValue and fill a struct oslDateTime.
SAL_DLLPUBLIC sal_uInt32 osl_getGlobalTimer(void)
Get the value of the global timer.
SAL_DLLPUBLIC sal_Bool osl_getTimeValueFromDateTime(const oslDateTime *pDateTime, TimeValue *pTimeVal)
Get the GMT from a oslDateTime and fill a TimeValue.
SAL_DLLPUBLIC sal_Bool osl_getLocalTimeFromSystemTime(const TimeValue *pSystemTimeVal, TimeValue *pLocalTimeVal)
Convert GMT to local time.
sal_uInt16 Day
is the day of month (1-31).
Definition: time.h:95
sal_uInt16 Seconds
contains the seconds (0-59).
Definition: time.h:83
#define SAL_DLLPUBLIC
Definition: saldllapi.h:14