LibreOffice
LibreOffice 5.3 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_OSL_TIME_H
21 #define INCLUDED_OSL_TIME_H
22 
23 #include <sal/config.h>
24 
25 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
26 #include <chrono>
27 #endif
28 
29 #include <sal/saldllapi.h>
30 #include <sal/types.h>
31 
32 /****************************************************************************/
33 /* TimeValue */
34 /****************************************************************************/
35 
36 #ifdef SAL_W32
37 # pragma pack(push, 8)
38 #endif
39 
40 /* Time since Jan-01-1970 */
41 
42 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
43 
44 struct TimeValue {
45  TimeValue() = default;
46 
47  SAL_CONSTEXPR TimeValue(sal_uInt32 seconds, sal_uInt32 nanoseconds):
48  Seconds(seconds), Nanosec(nanoseconds) {}
49 
50  template<typename Rep, typename Period> SAL_CONSTEXPR
51  TimeValue(std::chrono::duration<Rep, Period> const & duration):
52  Seconds(
53  std::chrono::duration_cast<std::chrono::nanoseconds>(
54  duration).count() / 1000000000),
55  Nanosec(
56  std::chrono::duration_cast<std::chrono::nanoseconds>(
57  duration).count() % 1000000000)
58  {}
59 
60  sal_uInt32 Seconds;
61  sal_uInt32 Nanosec;
62 };
63 
64 #else
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 typedef struct {
71  sal_uInt32 Seconds;
72  sal_uInt32 Nanosec;
73 } TimeValue;
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif
80 
81 #if defined(SAL_W32)
82 # pragma pack(pop)
83 #endif
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 /****************************************************************************/
90 /* oslDateTime */
91 /****************************************************************************/
92 
93 typedef struct _oslDateTime
94 {
95  /*----------------------------------------------------------------------*/
98  sal_uInt32 NanoSeconds;
99 
102  sal_uInt16 Seconds;
103 
104  /*----------------------------------------------------------------------*/
107  sal_uInt16 Minutes;
108 
109  /*----------------------------------------------------------------------*/
112  sal_uInt16 Hours;
113 
114  /*----------------------------------------------------------------------*/
117  sal_uInt16 Day;
118 
119  /*----------------------------------------------------------------------*/
122  sal_uInt16 DayOfWeek;
123 
124  /*----------------------------------------------------------------------*/
127  sal_uInt16 Month;
128 
129  /*----------------------------------------------------------------------*/
132  sal_Int16 Year;
133 
134 } oslDateTime;
135 
136 
141  TimeValue* pTimeVal );
142 
143 
151  const TimeValue* pTimeVal, oslDateTime* pDateTime );
152 
153 
161  const oslDateTime* pDateTime, TimeValue* pTimeVal );
162 
163 
171  const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
172 
173 
181  const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
182 
183 
188 SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif // INCLUDED_OSL_TIME_H
195 
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define SAL_DLLPUBLIC
Definition: saldllapi.h:30
sal_uInt32 Seconds
Definition: time.h:71
SAL_DLLPUBLIC sal_Bool osl_getLocalTimeFromSystemTime(const TimeValue *pSystemTimeVal, TimeValue *pLocalTimeVal)
Convert GMT to local time.
SAL_DLLPUBLIC sal_Bool osl_getSystemTimeFromLocalTime(const TimeValue *pLocalTimeVal, TimeValue *pSystemTimeVal)
Convert local time to GMT.
sal_uInt16 Hours
contains the hour (0-23).
Definition: time.h:112
sal_uInt32 Nanosec
Definition: time.h:72
SAL_DLLPUBLIC sal_Bool osl_getSystemTime(TimeValue *pTimeVal)
Get the current system time as TimeValue.
Definition: time.h:93
unsigned char sal_Bool
Definition: types.h:48
SAL_DLLPUBLIC sal_uInt32 osl_getGlobalTimer(void)
Get the value of the global timer.
sal_uInt32 NanoSeconds
contains the nanoseconds .
Definition: time.h:98
sal_uInt16 Minutes
contains the minutes (0-59).
Definition: time.h:107
SAL_DLLPUBLIC sal_Bool osl_getTimeValueFromDateTime(const oslDateTime *pDateTime, TimeValue *pTimeVal)
Get the GMT from a oslDateTime and fill a TimeValue.
sal_Int16 Year
is the year.
Definition: time.h:132
sal_uInt16 DayOfWeek
is the day of week (0-6 , 0 : Sunday).
Definition: time.h:122
sal_uInt16 Month
is the month of year (1-12).
Definition: time.h:127
#define SAL_CONSTEXPR
C++11 &quot;constexpr&quot; feature.
Definition: types.h:445
Definition: time.h:70
struct _oslDateTime oslDateTime
sal_uInt16 Day
is the day of month (1-31).
Definition: time.h:117
sal_uInt16 Seconds
contains the seconds (0-59).
Definition: time.h:102
SAL_DLLPUBLIC sal_Bool osl_getDateTimeFromTimeValue(const TimeValue *pTimeVal, oslDateTime *pDateTime)
Get the GMT from a TimeValue and fill a struct oslDateTime.