/// Equality comparator, timezone is checked
 inline bool identical(const flex_date_time& other) const{
   return posix_timestamp() == other.posix_timestamp() && 
       time_zone_offset() == other.time_zone_offset() &&
       microsecond() == other.microsecond();
 }
 /**
  * Returns the timestamp in a floating point value including the microsecond
  * interval.
  * \note This function is not generally safe since there are only 
  * 52 mantissa bits, We may lose precision for extremely large or 
  * extremely small timestamp values
  */
 inline double microsecond_res_timestamp() const {
   return double(posix_timestamp()) + double(microsecond()) / MICROSECONDS_PER_SECOND;
 }
 /// Equality comparator, timezone is ignored.
 inline bool operator==(const flex_date_time& other) const{
   return 
       posix_timestamp() == other.posix_timestamp() && 
       microsecond() == other.microsecond();
 }
Exemplo n.º 4
0
void DateTime::format(std::string& str, const std::string& fmt, int timeZoneDifferential)
{
    std::string::const_iterator it  = fmt.begin();
    std::string::const_iterator end = fmt.end();
    while (it != end)
    {
        if (*it == '%')
        {
            if (++it != end)
            {
                switch (*it)
                {
                case 'w': str.append(WEEKDAY_NAMES[dayOfWeek()], 0, 3); break;
                case 'W': str.append(WEEKDAY_NAMES[dayOfWeek()]); break;
                case 'b': str.append(MONTH_NAMES[month() - 1], 0, 3); break;
                case 'B': str.append(MONTH_NAMES[month() - 1]); break;
                case 'd': NumberFormatter::append0(str, (int32_t)day(), 2); break;
                case 'e': NumberFormatter::append(str, (int32_t)day()); break;
                case 'f': NumberFormatter::append(str, (int32_t)day(), 2); break;
                case 'm': NumberFormatter::append0(str, (int32_t)month(), 2); break;
                case 'n': NumberFormatter::append(str, (int32_t)month()); break;
                case 'o': NumberFormatter::append(str, (int32_t)month(), 2); break;
                case 'y': NumberFormatter::append0(str, (int32_t)year() % 100, 2); break;
                case 'Y': NumberFormatter::append0(str, (int32_t)year(), 4); break;
                case 'H': NumberFormatter::append0(str, (int32_t)hour(), 2); break;
                case 'h': NumberFormatter::append0(str, (int32_t)hourAMPM(), 2); break;
                case 'a': str.append(isAM() ? "am" : "pm"); break;
                case 'A': str.append(isAM() ? "AM" : "PM"); break;
                case 'M': NumberFormatter::append0(str, (int32_t)minute(), 2); break;
                case 'S': NumberFormatter::append0(str, (int32_t)second(), 2); break;
                case 'i': NumberFormatter::append0(str, (int32_t)millisecond(), 3); break;
                case 'c': NumberFormatter::append(str, (int32_t)millisecond()/100); break;
                case 'F': NumberFormatter::append0(str, (int32_t)millisecond()*1000 + microsecond(), 6); break;
                case 'z': tzdISO(str, timeZoneDifferential); break;
                case 'Z': tzdRFC(str, timeZoneDifferential); break;
                default:  str += *it;
                }
                ++it;
            }
        }
        else str += *it++;
    }
}