xref: /aoo42x/main/sal/inc/osl/time.h (revision 9eab2a37)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _OSL_TIME_H_
25 #define _OSL_TIME_H_
26 
27 #include <sal/types.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /****************************************************************************/
34 /* TimeValue                                                                */
35 /****************************************************************************/
36 
37 #ifdef SAL_W32
38 #	pragma pack(push, 8)
39 #elif defined(SAL_OS2)
40 #	pragma pack(push, 4)
41 #endif
42 
43 /* Time since Jan-01-1970 */
44 
45 typedef struct {
46     sal_uInt32 Seconds;
47     sal_uInt32 Nanosec;
48 } TimeValue;
49 
50 #if defined( SAL_W32) ||  defined(SAL_OS2)
51 #	pragma pack(pop)
52 #endif
53 
54 
55 /****************************************************************************/
56 /* oslDateTime */
57 /****************************************************************************/
58 
59 typedef struct _oslDateTime
60 {
61 	/*----------------------------------------------------------------------*/
62 	/** contains the nanoseconds .
63 	*/
64 	sal_uInt32 NanoSeconds;
65 
66 	/** contains the seconds (0-59).
67 	*/
68 	sal_uInt16 Seconds;
69 
70 	/*----------------------------------------------------------------------*/
71 	/** contains the minutes (0-59).
72 	*/
73 	sal_uInt16 Minutes;
74 
75 	/*----------------------------------------------------------------------*/
76 	/** contains the hour (0-23).
77 	*/
78 	sal_uInt16 Hours;
79 
80 	/*----------------------------------------------------------------------*/
81 	/** is the day of month (1-31).
82 	*/
83 	sal_uInt16 Day;
84 
85 	/*----------------------------------------------------------------------*/
86 	/** is the day of week (0-6 , 0 : Sunday).
87 	*/
88 	sal_uInt16 DayOfWeek;
89 
90 	/*----------------------------------------------------------------------*/
91 	/** is the month of year (1-12).
92 	*/
93 	sal_uInt16 Month;
94 
95 	/*----------------------------------------------------------------------*/
96 	/** is the year.
97 	*/
98 	sal_uInt16 Year;
99 
100 } oslDateTime;
101 
102 
103 /** Get the current system time as TimeValue.
104 	@return false if any error occurs.
105 */
106 sal_Bool SAL_CALL osl_getSystemTime( TimeValue* pTimeVal );
107 
108 
109 /** Get the GMT from a TimeValue and fill a struct oslDateTime
110 	@param pTimeVal[in] TimeValue
111 	@param pDateTime[out] On success it receives a struct oslDateTime
112 
113 	@return sal_False if any error occurs else sal_True.
114 */
115 sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( TimeValue* pTimeVal, oslDateTime* pDateTime );
116 
117 
118 /** Get the GMT from a oslDateTime and fill a TimeValue
119 	@param pDateTime[in] oslDateTime
120 	@param pTimeVal[out] On success it receives a TimeValue
121 
122 	@return sal_False if any error occurs else sal_True.
123 */
124 sal_Bool SAL_CALL osl_getTimeValueFromDateTime( oslDateTime* pDateTime, TimeValue* pTimeVal );
125 
126 
127 /** Convert GMT to local time
128 	@param pSystemTimeVal[in] system time to convert
129 	@param pLocalTimeVal[out] On success it receives the local time
130 
131 	@return sal_False if any error occurs else sal_True.
132 */
133 sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( TimeValue* pSystemTimeVal, TimeValue* pLocalTimeVal );
134 
135 
136 /** Convert local time to GMT
137 	@param pLocalTimeVal[in] local time to convert
138 	@param pSystemTimeVal[out] On success it receives the system time
139 
140 	@return sal_False if any error occurs else sal_True.
141 */
142 sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( TimeValue* pLocalTimeVal, TimeValue* pSystemTimeVal );
143 
144 
145 /** Get the value of the global timer
146     @return current timer value in milli seconds
147  */
148 
149 sal_uInt32 SAL_CALL osl_getGlobalTimer(void);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif	/* _OSL_TIME_H_ */
156 
157