29 const std::time_t minute = 60U ;
30 const std::time_t hour = 60U * minute ;
31 const std::time_t day = 24U * hour ;
36 return std::time(NULL) ;
46 const std::time_t delta = minute * 30U ;
47 for(
EpochTime t = (start-day-delta) ; t <= (start+day+delta) ; t += delta )
49 if( equivalent( t , bdt_in ) )
59 G::DateTime::gmtime_r( &epoch_time , &result ) ;
67 G::DateTime::localtime_r( &epoch_time , &bdt_local ) ;
76 bool ahead = local >= utc ;
77 EpochTime n = ahead ? (local-utc) : (utc-local) ;
78 return Offset( ahead , static_cast<unsigned int>(n) ) ;
83 unsigned int hh = offset.second / 3600U ;
84 unsigned int mm = (offset.second / 60U) % 60 ;
86 std::ostringstream ss ;
87 char sign = (offset.first || (hh==0&&mm==0)) ?
'+' :
'-' ;
88 ss << sign << (hh/10U) << (hh%10U) << (mm/10) << (mm%10) ;
92 bool G::DateTime::equivalent( EpochTime t ,
const BrokenDownTime & bdt_in )
94 BrokenDownTime bdt_test = utc(t) ;
95 return same( bdt_test , bdt_in ) ;
98 bool G::DateTime::same(
const BrokenDownTime & bdt1 ,
const BrokenDownTime & bdt2 )
101 bdt1.tm_mday == bdt2.tm_mday &&
102 bdt1.tm_hour == bdt2.tm_hour &&
103 bdt1.tm_min == bdt2.tm_min ;
static BrokenDownTime utc(EpochTime epoch_time)
Converts from epoch time to UTC broken-down-time.
static EpochTime now()
Returns the current epoch time.
static Offset offset(EpochTime epoch_time)
Returns the offset between UTC and localtime as at 'epoch_time'.
static BrokenDownTime local(EpochTime epoch_time)
Converts from epoch time to local broken-down-time.
std::pair< bool, unsigned int > Offset
static std::string offsetString(Offset offset)
Converts the given utc/localtime offset into a five-character "+/-hhmm" string.
struct std::tm BrokenDownTime
static EpochTime epochTime(const BrokenDownTime &broken_down_time)
Converts from UTC broken-down-time to epoch time.