Branch libreoffice-5-0-4
[LibreOffice.git] / include / osl / time.h
blob335f552e74674c585c8c03f322209fca7246093b
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 .
20 #ifndef INCLUDED_OSL_TIME_H
21 #define INCLUDED_OSL_TIME_H
23 #include <sal/config.h>
25 #include <sal/saldllapi.h>
26 #include <sal/types.h>
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 /****************************************************************************/
33 /* TimeValue */
34 /****************************************************************************/
36 #ifdef SAL_W32
37 # pragma pack(push, 8)
38 #endif
40 /* Time since Jan-01-1970 */
42 typedef struct {
43 sal_uInt32 Seconds;
44 sal_uInt32 Nanosec;
45 } TimeValue;
47 #if defined(SAL_W32)
48 # pragma pack(pop)
49 #endif
52 /****************************************************************************/
53 /* oslDateTime */
54 /****************************************************************************/
56 typedef struct _oslDateTime
58 /*----------------------------------------------------------------------*/
59 /** contains the nanoseconds .
61 sal_uInt32 NanoSeconds;
63 /** contains the seconds (0-59).
65 sal_uInt16 Seconds;
67 /*----------------------------------------------------------------------*/
68 /** contains the minutes (0-59).
70 sal_uInt16 Minutes;
72 /*----------------------------------------------------------------------*/
73 /** contains the hour (0-23).
75 sal_uInt16 Hours;
77 /*----------------------------------------------------------------------*/
78 /** is the day of month (1-31).
80 sal_uInt16 Day;
82 /*----------------------------------------------------------------------*/
83 /** is the day of week (0-6 , 0 : Sunday).
85 sal_uInt16 DayOfWeek;
87 /*----------------------------------------------------------------------*/
88 /** is the month of year (1-12).
90 sal_uInt16 Month;
92 /*----------------------------------------------------------------------*/
93 /** is the year.
95 sal_Int16 Year;
97 } oslDateTime;
100 /** Get the current system time as TimeValue.
101 @return false if any error occurs.
103 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTime(
104 TimeValue* pTimeVal );
107 /** Get the GMT from a TimeValue and fill a struct oslDateTime
108 @param[in] pTimeVal TimeValue
109 @param[out] pDateTime On success it receives a struct oslDateTime
111 @return sal_False if any error occurs else sal_True.
113 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getDateTimeFromTimeValue(
114 const TimeValue* pTimeVal, oslDateTime* pDateTime );
117 /** Get the GMT from a oslDateTime and fill a TimeValue
118 @param[in] pDateTime oslDateTime
119 @param[out] pTimeVal On success it receives a TimeValue
121 @return sal_False if any error occurs else sal_True.
123 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getTimeValueFromDateTime(
124 const oslDateTime* pDateTime, TimeValue* pTimeVal );
127 /** Convert GMT to local time
128 @param[in] pSystemTimeVal system time to convert
129 @param[out] pLocalTimeVal On success it receives the local time
131 @return sal_False if any error occurs else sal_True.
133 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime(
134 const TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
137 /** Convert local time to GMT
138 @param[in] pLocalTimeVal local time to convert
139 @param[out] pSystemTimeVal On success it receives the system time
141 @return sal_False if any error occurs else sal_True.
143 SAL_DLLPUBLIC sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime(
144 const TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
147 /** Get the value of the global timer
148 @return current timer value in milli seconds
151 SAL_DLLPUBLIC sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
153 #ifdef __cplusplus
155 #endif
157 #endif // INCLUDED_OSL_TIME_H
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */