if (virTimeMillisNowRaw(&now) < 0)
return -1;
- return virTimeFieldsThenRaw(now, fields);
+ virTimeFieldsThen(now, fields);
+
+ return 0;
}
((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))
/**
- * virTimeFieldsThenRaw:
+ * virTimeFieldsThen:
* @when: the time to convert in milliseconds
* @fields: filled with time @when fields
*
* Converts the timestamp @when into broken-down field format.
* Time time is always in UTC
*
- * Returns 0 on success, -1 on error with errno set
*/
-int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
+void virTimeFieldsThen(unsigned long long when, struct tm *fields)
{
/* This code is taken from GLibC under terms of LGPLv2+ */
long int days, rem, y;
days -= ip[y];
fields->tm_mon = y;
fields->tm_mday = days + 1;
- return 0;
}
{
struct tm fields;
- if (virTimeFieldsThenRaw(when, &fields) < 0)
- return -1;
+ virTimeFieldsThen(when, &fields);
fields.tm_year += 1900;
fields.tm_mon += 1;
if (virTimeMillisNow(&now) < 0)
return -1;
- return virTimeFieldsThen(now, fields);
-}
-
-
-/**
- * virTimeFieldsThen:
- * @when: the time to convert in milliseconds
- * @fields: filled with time @when fields
- *
- * Converts the timestamp @when into broken-down field format.
- * Time time is always in UTC
- *
- * Returns 0 on success, -1 on error with error reported
- */
-int virTimeFieldsThen(unsigned long long when, struct tm *fields)
-{
- if (virTimeFieldsThenRaw(when, fields) < 0) {
- virReportSystemError(errno, "%s",
- _("Unable to break out time format"));
- return -1;
- }
+ virTimeFieldsThen(now, fields);
return 0;
}
(4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 5 + 1)
/* Yr Mon Day Hour Min Sec Ms TZ NULL */
+void virTimeFieldsThen(unsigned long long when, struct tm *fields)
+ ATTRIBUTE_NONNULL(2);
+
/* These APIs are async signal safe and return -1, setting
* errno on failure */
int virTimeMillisNowRaw(unsigned long long *now)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeFieldsNowRaw(struct tm *fields)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virTimeFieldsThenRaw(unsigned long long when, struct tm *fields)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
int virTimeStringNowRaw(char *buf)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeStringThenRaw(unsigned long long when, char *buf)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virTimeFieldsNow(struct tm *fields)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
-int virTimeFieldsThen(unsigned long long when, struct tm *fields)
- ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
char *virTimeStringNow(void);
char *virTimeStringThen(unsigned long long when);