* @param tm Time to format as broken-down \c struct tm.
* @param date Include the day part ([-]YYYY-MM-DD).
* @param time Include the time part (hh:mm:ss).
- * @param tz Include the timezone ([±]ZZZZ); only heeded if
+ * @param tz Include the timezone ([±]ZZZZ); only needed if
* \c time is requested as well.
*
* @return The formatted timestamp.
}
/*
- * The sign is *always* handled above so the formatted string her
+ * The sign is *always* handled above so the formatted string here
* is always one character shorter.
- * */
- const size_t n = strftime (start, iso8601::bufsize-1, format, &tmp);
+ */
+ if (strftime (start, iso8601::bufsize-1, format, &tmp) == 0)
+ {
+ return std::string ();
+ }
- buf [n+1] = '\0';
+ buf [iso8601::bufsize-1] = '\0'; /* Just in case. */
return std::string (buf);
}
{
char ms [4] = { '\0', '\0', '\0', '\0' };
- if (snprintf (ms, 4, "%0.3ld", ts.tv_nsec / 1000000) < 0) {
+ if (snprintf (ms, 4, "%.3ld", ts.tv_nsec / 1000000) < 0) {
return boost::none;
}