13 using namespace Gaudi;
    63 #define SECS_1601_TO_1970 ( ( 369 * 365 + 89 ) * 86400ui64 )    67 static time_t timegm( 
struct tm* t )
    72   gmtime_s( &gmt, &t1 );
    73   time_t t2 = 
mktime( &gmt );
    74   return t1 + ( t1 - t2 );
    84   memset( &val, 0, 
sizeof( val ) );
    90   val.tm_year  = year > 1900 ? year - 1900 : 
year;
    99 Time Time::from( 
const FILETIME* systime )
   105     t = ( t - SECS_1601_TO_1970 * ( 
SEC_NSECS / 100 ) ) * 100;
   116   GetSystemTimeAsFileTime( &ftime );
   117   return from( &ftime );
   120   if ( gettimeofday( &tv, 
nullptr ) != 0 ) {
   123     tag << 
"errno=" << errno;
   124     if ( strerror_r( errno, buf, 256 ) == 0 ) {
   127       msg << 
"Unknown error retrieving current time";
   131   return Time( tv.tv_sec, tv.tv_usec * 1000 );
   139   return Time( local ? mktime( &tmp ) : timegm( &tmp ), 0 ) + diff;
   150   time_t val = ( time_t )( 
m_nsecs / SEC_NSECS );
   154     localtime_r( &val, &retval );
   156     gmtime_r( &val, &retval );
   215   tm localtm                = 
local();
   216   n                         = localtm.tm_gmtoff;
   217   if ( daylight ) *daylight = localtm.tm_isdst;
   222   localtime_s( &localtm, &utctime );
   223   int savedaylight = localtm.tm_isdst;
   225   gmtime_s( &gmt, &utctime );
   227   gmt.tm_isdst = savedaylight;
   228   n            = utctime - mktime( &gmt );
   230   if ( daylight ) *daylight = savedaylight;
   238 #pragma warning( push )   239 #pragma warning( disable : 4996 )   247   tm localtm                = 
local();
   248   if ( daylight ) *daylight = localtm.tm_isdst;
   250   return tzname[localtm.tm_isdst > 0 ? 1 : 0];
   253 #pragma warning( pop )   265   std::string::size_type length = 0;
   268   std::string::size_type pos = spec.
find( 
"%f" );
   269   if ( std::string::npos != pos ) {
   273     while ( std::string::npos != pos ) {
   274       if ( pos != 0 && spec[pos - 1] != 
'%' ) {
   277       pos = spec.
find( 
"%f", pos + 1 ); 
   280   const int MIN_BUF_SIZE = 128;
   283     result.
resize( std::max<std::string::size_type>(
   284                        result.
size() * 2, std::max<std::string::size_type>( spec.
size() * 2, MIN_BUF_SIZE ) ),
   286     length = ::strftime( &result[0], result.
size(), spec.
c_str(), &
time );
   305   TimeAssert( ( minwidth >= 1 ) && ( minwidth <= maxwidth ) && ( maxwidth <= 9 ),
   306               "nanoformat options do not satisfy: 1 <= minwidth <= maxwidth <= 9" );
   330   struct tm localtm = time.
local();
   332   unsigned mday = localtm.tm_mday;
   333   unsigned mon  = localtm.tm_mon + 1;
   334   unsigned year = ( localtm.tm_year > 80 ? localtm.tm_year - 80 : 0 );
   335   unsigned sec  = localtm.tm_sec / 2;
   336   unsigned min  = localtm.tm_min;
   337   unsigned hour = localtm.tm_hour;
   338   return ( mday << 16 | mon << 21 | year << 25 | sec | min << 5 | hour << 11 );
   349   memset( &localtm, 0, 
sizeof( localtm ) );
   350   localtm.tm_mday  = ( dosDate >> 16 ) & 0x1f;
   351   localtm.tm_mon   = ( ( dosDate >> 21 ) & 0xf ) - 1;
   352   localtm.tm_year  = ( ( dosDate >> 25 ) & 0x7f ) + 80;
   353   localtm.tm_hour  = ( dosDate >> 11 ) & 0x1f;
   354   localtm.tm_min   = ( dosDate >> 5 ) & 0x3f;
   355   localtm.tm_sec   = ( dosDate & 0x1f ) * 2;
   356   localtm.tm_isdst = -1;
   358   return Time( mktime( &localtm ), 0 );
 
int hour(bool local) const 
Get the hour, numbered [0, 23]. 
 
Time()=default
Initialize an empty (zero) time value. 
 
const char * timezone(int *daylight=0) const 
Return the local timezone name that applies at this time value. 
 
tm split(bool local, int *nsecpart=0) const 
Break up the time to the standard representation, either in UTC (if local is false) or local time (if...
 
static Time build(bool local, const tm &base, TimeSpan diff=0)
Construct a time from local time base and a delta diff. 
 
Define general base for Gaudi exception. 
 
int day(bool local) const 
Get the day of month, numbered [1,31]. 
 
static unsigned toDosDate(Time time)
Convert the Time t into a MS-DOS date format. 
 
int month(bool local) const 
Get the month, numbered [0,11]. 
 
tm utc(int *nsecpart=0) const 
Break up the time to the standard library representation, keeping it in UTC. 
 
static Time current()
Returns the current time. 
 
bool isdst(bool local) const 
Check whether daylight savings is in effect. 
 
void TimeAssert(bool cond, const std::string &msg="time assertion failed") const 
 
int second(bool local) const 
Get the seconds, numbered [0,61] (allowing one or two leap seconds, years with leap seconds can have ...
 
tm local(int *nsecpart=0) const 
Break up the time to the standard library representation, converting it first to local time...
 
static const ValueType SEC_NSECS
Nanoseconds in one second. 
 
ValueType utcoffset(int *daylight=0) const 
Return the number of nanoseconds that needs to be added to UTC to translate this time to the local ti...
 
std::string nanoformat(size_t minwidth=1, size_t maxwidth=9) const 
Format the nanosecond fractional part of the time as a string. 
 
static Time fromDosDate(unsigned dosDate)
Convert the MS-DOS date dosDate into a Time. 
 
T find_last_not_of(T...args)
 
int nsecond() const 
Get the nanoseconds. 
 
int weekday(bool local) const 
Get the day of week, numbered [0,6] and starting from Sunday. 
 
int year(bool local) const 
Get the year. 
 
Helper functions to set/get the application return code. 
 
std::string format(bool local, std::string spec="%c") const 
Format the time using strftime. 
 
int minute(bool local) const 
Get the minute, numbered [0, 59].