00001 //Dear emacs, this is -*- c++ -*- 00002 00013 #include "eformat/DateAndTime.h" 00014 #include <ctime> 00015 00016 eformat::helper::DateAndTime::DateAndTime () 00017 : m_val(time(0)) 00018 { 00019 } 00020 00021 eformat::helper::DateAndTime::DateAndTime (uint32_t val) 00022 : m_val(val) 00023 { 00024 } 00025 00026 std::string eformat::helper::DateAndTime::iso8601 (void) const 00027 { 00028 struct tm t; 00029 time_t val = code(); 00030 gmtime_r(&val, &t); 00031 char buf[100]; 00032 strftime(buf, 100, "%Y-%m-%dT%H:%M:%SZ", &t); 00033 return buf; 00034 } 00035 00036 std::string eformat::helper::DateAndTime::human (void) const 00037 { 00038 struct tm t; 00039 time_t val = code(); 00040 gmtime_r(&val, &t); 00041 char buf[100]; 00042 strftime(buf, 100, "%a, %d %b %Y %H:%M:%S UTC", &t); 00043 return buf; 00044 }