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