from_tm:
x = mktime_or_timegm(&tm, utc);
- if (x < 0)
- return -EINVAL;
+ if (x == (time_t) -1)
+ return -EOVERFLOW;
if (weekday >= 0 && tm.tm_wday != weekday)
return -EINVAL;
- ret = (usec_t) x * USEC_PER_SEC + x_usec;
+ if (x < 0)
+ ret = 0;
+ else
+ ret = (usec_t) x * USEC_PER_SEC + x_usec;
+
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
finish:
if (ret + plus < ret) /* overflow? */
- return -EINVAL;
+ return -EOVERFLOW;
ret += plus;
if (ret > USEC_TIMESTAMP_FORMATTABLE_MAX)
return -EINVAL;
}
#if 0 /// UNNEEDED by elogind
+int parse_sec_fix_0(const char *t, usec_t *usec) {
+ t += strspn(t, WHITESPACE);
+ if (streq(t, "0")) {
+ *usec = USEC_INFINITY;
+ return 0;
+ }
+
+ return parse_sec(t, usec);
+}
+
int parse_nsec(const char *t, nsec_t *nsec) {
static const struct {
const char *suffix;