xref: /trunk/main/sal/inc/osl/time.h (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _OSL_TIME_H_
29 #define _OSL_TIME_H_
30 
31 #include <sal/types.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /****************************************************************************/
38 /* TimeValue                                                                */
39 /****************************************************************************/
40 
41 #ifdef SAL_W32
42 #   pragma pack(push, 8)
43 #elif defined(SAL_OS2)
44 #   pragma pack(push, 4)
45 #endif
46 
47 /* Time since Jan-01-1970 */
48 
49 typedef struct {
50     sal_uInt32 Seconds;
51     sal_uInt32 Nanosec;
52 } TimeValue;
53 
54 #if defined( SAL_W32) ||  defined(SAL_OS2)
55 #   pragma pack(pop)
56 #endif
57 
58 
59 /****************************************************************************/
60 /* oslDateTime */
61 /****************************************************************************/
62 
63 typedef struct _oslDateTime
64 {
65     /*----------------------------------------------------------------------*/
66     /** contains the nanoseconds .
67     */
68     sal_uInt32 NanoSeconds;
69 
70     /** contains the seconds (0-59).
71     */
72     sal_uInt16 Seconds;
73 
74     /*----------------------------------------------------------------------*/
75     /** contains the minutes (0-59).
76     */
77     sal_uInt16 Minutes;
78 
79     /*----------------------------------------------------------------------*/
80     /** contains the hour (0-23).
81     */
82     sal_uInt16 Hours;
83 
84     /*----------------------------------------------------------------------*/
85     /** is the day of month (1-31).
86     */
87     sal_uInt16 Day;
88 
89     /*----------------------------------------------------------------------*/
90     /** is the day of week (0-6 , 0 : Sunday).
91     */
92     sal_uInt16 DayOfWeek;
93 
94     /*----------------------------------------------------------------------*/
95     /** is the month of year (1-12).
96     */
97     sal_uInt16 Month;
98 
99     /*----------------------------------------------------------------------*/
100     /** is the year.
101     */
102     sal_uInt16 Year;
103 
104 } oslDateTime;
105 
106 
107 /** Get the current system time as TimeValue.
108     @return false if any error occurs.
109 */
110 sal_Bool SAL_CALL osl_getSystemTime( TimeValue* pTimeVal );
111 
112 
113 /** Get the GMT from a TimeValue and fill a struct oslDateTime
114     @param pTimeVal[in] TimeValue
115     @param pDateTime[out] On success it receives a struct oslDateTime
116 
117     @return sal_False if any error occurs else sal_True.
118 */
119 sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime );
120 
121 
122 /** Get the GMT from a oslDateTime and fill a TimeValue
123     @param pDateTime[in] oslDateTime
124     @param pTimeVal[out] On success it receives a TimeValue
125 
126     @return sal_False if any error occurs else sal_True.
127 */
128 sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal );
129 
130 
131 /** Convert GMT to local time
132     @param pSystemTimeVal[in] system time to convert
133     @param pLocalTimeVal[out] On success it receives the local time
134 
135     @return sal_False if any error occurs else sal_True.
136 */
137 sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
138 
139 
140 /** Convert local time to GMT
141     @param pLocalTimeVal[in] local time to convert
142     @param pSystemTimeVal[out] On success it receives the system time
143 
144     @return sal_False if any error occurs else sal_True.
145 */
146 sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
147 
148 
149 /** Get the value of the global timer
150     @return current timer value in milli seconds
151  */
152 
153 sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif  /* _OSL_TIME_H_ */
160 
161