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 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
47 TimeValue() = default;
49 constexpr TimeValue(sal_uInt32 seconds
, sal_uInt32 nanoseconds
):
50 Seconds(seconds
), Nanosec(nanoseconds
) {}
52 template<typename Rep
, typename Period
> constexpr
53 TimeValue(std::chrono::duration
<Rep
, Period
> const & duration
):
55 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
56 duration
).count() / 1000000000),
58 std::chrono::duration_cast
<std::chrono::nanoseconds
>(
59 duration
).count() % 1000000000)
91 typedef struct _oslDateTime
93 /** contains the nanoseconds
95 sal_uInt32 NanoSeconds
;
97 /** contains the seconds (0-59).
101 /** contains the minutes (0-59).
105 /** contains the hour (0-23).
109 /** is the day of month (1-31).
113 /** is the day of week (0-6 , 0 : Sunday).
115 sal_uInt16 DayOfWeek
;
117 /** is the month of year (1-12).
128 /** Get the current system time as TimeValue.
129 @retval false if any error occurs.
131 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTime(
132 TimeValue
* pTimeVal
);
135 /** Get the GMT from a TimeValue and fill a struct oslDateTime
136 @param[in] pTimeVal TimeValue
137 @param[out] pDateTime On success it receives a struct oslDateTime
139 @return sal_False if any error occurs else sal_True.
141 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getDateTimeFromTimeValue(
142 const TimeValue
* pTimeVal
, oslDateTime
* pDateTime
);
145 /** Get the GMT from a oslDateTime and fill a TimeValue
146 @param[in] pDateTime oslDateTime
147 @param[out] pTimeVal On success it receives a TimeValue
149 @return sal_False if any error occurs else sal_True.
151 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getTimeValueFromDateTime(
152 const oslDateTime
* pDateTime
, TimeValue
* pTimeVal
);
155 /** Convert GMT to local time
156 @param[in] pSystemTimeVal system time to convert
157 @param[out] pLocalTimeVal On success it receives the local time
159 @return sal_False if any error occurs else sal_True.
161 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getLocalTimeFromSystemTime(
162 const TimeValue
* pSystemTimeVal
, TimeValue
* pLocalTimeVal
);
165 /** Convert local time to GMT
166 @param[in] pLocalTimeVal local time to convert
167 @param[out] pSystemTimeVal On success it receives the system time
169 @return sal_False if any error occurs else sal_True.
171 SAL_DLLPUBLIC sal_Bool SAL_CALL
osl_getSystemTimeFromLocalTime(
172 const TimeValue
* pLocalTimeVal
, TimeValue
* pSystemTimeVal
);
175 /** Get the value of the global timer
176 @return current timer value in milliseconds
179 SAL_DLLPUBLIC sal_uInt32 SAL_CALL
osl_getGlobalTimer(void);
185 #endif // INCLUDED_OSL_TIME_H
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */