snprintf (
buffer, sizeof (buffer),
"%sT%s%s%02d:%02d",
- date().c_str(), time_of_day(with_millisecond).c_str(), (_tz_hour >= 0 ? "+" : "-"), abs (_tz_hour), _tz_minute
+ date().c_str(), time_of_day(true, with_millisecond).c_str(), (_tz_hour >= 0 ? "+" : "-"), abs (_tz_hour), _tz_minute
);
return buffer;
}
/** @return The time in the form HH:MM:SS or HH:MM:SS.mmm */
string
-LocalTime::time_of_day (bool with_millisecond) const
+LocalTime::time_of_day (bool with_second, bool with_millisecond) const
{
char buffer[32];
+ DCP_ASSERT(!(with_millisecond && !with_second));
if (with_millisecond) {
snprintf (buffer, sizeof (buffer), "%02d:%02d:%02d.%03d", _hour, _minute, _second, _millisecond);
- } else {
+ } else if (with_second) {
snprintf (buffer, sizeof (buffer), "%02d:%02d:%02d", _hour, _minute, _second);
+ } else {
+ snprintf (buffer, sizeof (buffer), "%02d:%02d", _hour, _minute);
}
return buffer;
}
std::string as_string (bool with_millisecond = false) const;
std::string date () const;
- std::string time_of_day (bool with_millisecond = false) const;
+ std::string time_of_day (bool with_second, bool with_millisecond) const;
bool operator== (LocalTime const & other) const;
bool operator!= (LocalTime const & other) const;