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 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_OSL_TIME_H
25 #define INCLUDED_OSL_TIME_H
27 #include "sal/config.h"
29 #if defined LIBO_INTERNAL_ONLY
30 #if defined __cplusplus
35 #include "sal/saldllapi.h"
36 #include "sal/types.h"
39 # pragma pack(push, 8)
42 /** Time since Jan-01-1970
44 @warning sal_uInt32 TimeValue::Seconds is only large enough for representing dates until year
48 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
51 TimeValue() = default;
53 constexpr TimeValue(sal_uInt32 seconds
, sal_uInt32 nanoseconds
):
54 Seconds(seconds
), Nanosec(nanoseconds
) {}
56 template<typename Rep
, typename Period
> constexpr
57 TimeValue(std::chrono::duration
<Rep
, Period
> const & duration
):
59 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
60 duration
).count() / 1000000000),
62 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
63 duration
).count() % 1000000000)
95 typedef struct _oslDateTime
97 /** contains the nanoseconds
99 sal_uInt32 NanoSeconds
;
101 /** contains the seconds (0-59).
105 /** contains the minutes (0-59).
109 /** contains the hour (0-23).
113 /** is the day of month (1-31).
117 /** is the day of week (0-6 , 0 : Sunday).
119 sal_uInt16 DayOfWeek
;
121 /** is the month of year (1-12).
132 /** Get the current system time as TimeValue.
133 @retval false if any error occurs.
135 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTime(
136 TimeValue
* pTimeVal
);
139 /** Get the GMT from a TimeValue and fill a struct oslDateTime
140 @param[in] pTimeVal TimeValue
141 @param[out] pDateTime On success it receives a struct oslDateTime
143 @return sal_False if any error occurs else sal_True.
145 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getDateTimeFromTimeValue(
146 const TimeValue
* pTimeVal
, oslDateTime
* pDateTime
);
149 /** Get the GMT from a oslDateTime and fill a TimeValue
150 @param[in] pDateTime oslDateTime
151 @param[out] pTimeVal On success it receives a TimeValue
153 @return sal_False if any error occurs else sal_True.
155 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getTimeValueFromDateTime(
156 const oslDateTime
* pDateTime
, TimeValue
* pTimeVal
);
159 /** Convert GMT to local time
160 @param[in] pSystemTimeVal system time to convert
161 @param[out] pLocalTimeVal On success it receives the local time
163 @return sal_False if any error occurs else sal_True.
165 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getLocalTimeFromSystemTime(
166 const TimeValue
* pSystemTimeVal
, TimeValue
* pLocalTimeVal
);
169 /** Convert local time to GMT
170 @param[in] pLocalTimeVal local time to convert
171 @param[out] pSystemTimeVal On success it receives the system time
173 @return sal_False if any error occurs else sal_True.
175 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTimeFromLocalTime(
176 const TimeValue
* pLocalTimeVal
, TimeValue
* pSystemTimeVal
);
179 /** Get the value of the global timer
180 @return current timer value in milliseconds
183 SAL_DLLPUBLIC sal_uInt32 SAL_CALL
osl_getGlobalTimer(void);
189 #endif // INCLUDED_OSL_TIME_H
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */