Go to the documentation of this file.00001 #ifndef acsutilTime_H
00002 #define acsutilTime_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037
00038 #include <acscommonC.h>
00039 #include <SString.h>
00040 #include <OS_NS_time.h>
00041
00072 #if defined (ACE_LACKS_LONGLONG_T)
00073 static const CORBA::ULongLong UTCtoUNIXTimeBaseOffset (0xD8539C80, 2);
00074
00075 #else
00076 static const CORBA::ULongLong UTCtoUNIXTimeBaseOffset = ACE_UINT64_LITERAL(0x2D8539C80);
00077 #endif
00078
00079
00084 ACS::Time getTimeStamp();
00085
00091 ACS::TimeInterval getTime();
00092
00097 ACE_CString getStringifiedTimeStamp();
00098
00099 inline ACE_Time_Value UTCtoACE_Time_Value(const ACS::Time &time)
00100 {
00101 ACS::Time seconds = time / static_cast<ACE_UINT32>(10000000);
00102 ACS::Time microseconds = (time % static_cast<ACE_UINT32>(10000000)) / 10;
00103 return ACE_Time_Value (ACE_U64_TO_U32 (seconds),
00104 ACE_U64_TO_U32 (microseconds));
00105 }
00106
00111 inline ACE_CString getStringifiedUTC(ACS::TimeInterval time)
00112 {
00113 ACE_TCHAR str[24];
00114 ACE_TCHAR ctp[20];
00115
00116
00117 time -= UTCtoUNIXTimeBaseOffset * ACE_static_cast(ACE_UINT32, 10000000);
00118
00119 ACE_Time_Value tv = UTCtoACE_Time_Value(time);
00120
00121 time_t ut(tv.sec());
00122 struct tm *utc_p = ACE_OS::gmtime(&ut);
00123 ACE_OS::strftime(ctp, sizeof(ctp), "%Y-%m-%dT%H:%M:%S", utc_p);
00124
00125 ACE_OS::sprintf (str, ACE_TEXT ("%s.%03ld"),
00126 ctp, tv.usec () / 1000);
00127
00128 return str;
00129 }
00130
00131 #endif
00132