1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OSL_TIME_H
21 #define INCLUDED_OSL_TIME_H
23 #include "sal/config.h"
25 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
29 #include "sal/saldllapi.h"
30 #include "sal/types.h"
33 # pragma pack(push, 8)
36 /* Time since Jan-01-1970 */
38 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
41 TimeValue() = default;
43 constexpr TimeValue(sal_uInt32 seconds
, sal_uInt32 nanoseconds
):
44 Seconds(seconds
), Nanosec(nanoseconds
) {}
46 template<typename Rep
, typename Period
> constexpr
47 TimeValue(std::chrono::duration
<Rep
, Period
> const & duration
):
49 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
50 duration
).count() / 1000000000),
52 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
53 duration
).count() % 1000000000)
85 typedef struct _oslDateTime
87 /** contains the nanoseconds
89 sal_uInt32 NanoSeconds
;
91 /** contains the seconds (0-59).
95 /** contains the minutes (0-59).
99 /** contains the hour (0-23).
103 /** is the day of month (1-31).
107 /** is the day of week (0-6 , 0 : Sunday).
109 sal_uInt16 DayOfWeek
;
111 /** is the month of year (1-12).
122 /** Get the current system time as TimeValue.
123 @retval false if any error occurs.
125 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTime(
126 TimeValue
* pTimeVal
);
129 /** Get the GMT from a TimeValue and fill a struct oslDateTime
130 @param[in] pTimeVal TimeValue
131 @param[out] pDateTime On success it receives a struct oslDateTime
133 @return sal_False if any error occurs else sal_True.
135 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getDateTimeFromTimeValue(
136 const TimeValue
* pTimeVal
, oslDateTime
* pDateTime
);
139 /** Get the GMT from a oslDateTime and fill a TimeValue
140 @param[in] pDateTime oslDateTime
141 @param[out] pTimeVal On success it receives a TimeValue
143 @return sal_False if any error occurs else sal_True.
145 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getTimeValueFromDateTime(
146 const oslDateTime
* pDateTime
, TimeValue
* pTimeVal
);
149 /** Convert GMT to local time
150 @param[in] pSystemTimeVal system time to convert
151 @param[out] pLocalTimeVal On success it receives the local time
153 @return sal_False if any error occurs else sal_True.
155 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getLocalTimeFromSystemTime(
156 const TimeValue
* pSystemTimeVal
, TimeValue
* pLocalTimeVal
);
159 /** Convert local time to GMT
160 @param[in] pLocalTimeVal local time to convert
161 @param[out] pSystemTimeVal On success it receives the system time
163 @return sal_False if any error occurs else sal_True.
165 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTimeFromLocalTime(
166 const TimeValue
* pLocalTimeVal
, TimeValue
* pSystemTimeVal
);
169 /** Get the value of the global timer
170 @return current timer value in milliseconds
173 SAL_DLLPUBLIC sal_uInt32 SAL_CALL
osl_getGlobalTimer(void);
179 #endif // INCLUDED_OSL_TIME_H
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */