Drop redundant 'using rtl::OUString'
[LibreOffice.git] / include / osl / time.h
blob5c5096cada8ae5a719de8f1095f0e8ba59b58736
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
31 #include <chrono>
32 #endif
33 #endif
35 #include "sal/saldllapi.h"
36 #include "sal/types.h"
38 #ifdef _WIN32
39 # pragma pack(push, 8)
40 #endif
42 /* Time since Jan-01-1970 */
44 #if defined LIBO_INTERNAL_ONLY && defined __cplusplus
46 struct TimeValue {
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):
54 Seconds(
55 std::chrono::duration_cast<std::chrono::nanoseconds>(
56 duration).count() / 1000000000),
57 Nanosec(
58 std::chrono::duration_cast<std::chrono::nanoseconds>(
59 duration).count() % 1000000000)
62 sal_uInt32 Seconds;
63 sal_uInt32 Nanosec;
66 #else
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
72 typedef struct {
73 sal_uInt32 Seconds;
74 sal_uInt32 Nanosec;
75 } TimeValue;
77 #ifdef __cplusplus
79 #endif
81 #endif
83 #if defined(_WIN32)
84 # pragma pack(pop)
85 #endif
87 #ifdef __cplusplus
88 extern "C" {
89 #endif
91 typedef struct _oslDateTime
93 /** contains the nanoseconds
95 sal_uInt32 NanoSeconds;
97 /** contains the seconds (0-59).
99 sal_uInt16 Seconds;
101 /** contains the minutes (0-59).
103 sal_uInt16 Minutes;
105 /** contains the hour (0-23).
107 sal_uInt16 Hours;
109 /** is the day of month (1-31).
111 sal_uInt16 Day;
113 /** is the day of week (0-6 , 0 : Sunday).
115 sal_uInt16 DayOfWeek;
117 /** is the month of year (1-12).
119 sal_uInt16 Month;
121 /** is the year.
123 sal_Int16 Year;
125 } oslDateTime;
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);
181 #ifdef __cplusplus
183 #endif
185 #endif // INCLUDED_OSL_TIME_H
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */