43#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
44# define GMTOFF(tm) ((tm)->tm_gmtoff)
47# define GMTOFF(tm) (-timezone+daylight)
50#define HOUR_SECONDS (60 * 60)
51#define DAY_SECONDS (HOUR_SECONDS * 24)
65#define valid_sec_usec(sec, usec) \
66 ((QB_ABS(usec) < QB_TIME_US_IN_SEC) \
67 && (((sec) == 0) || ((usec) == 0) || (((sec) < 0) == ((usec) < 0))))
79static crm_time_t *parse_date(
const char *date_str);
92 utc->years = dt->years;
94 utc->seconds = dt->seconds;
101 utc->months = dt->months;
115 if (date_time == NULL) {
118 return parse_date(date_time);
145 return (t != NULL) && (t->years || t->months || t->days || t->seconds
146 || t->offset || t->duration);
180 int YY = (year - 1) % 100;
181 int C = (year - 1) - YY;
183 int jan1 = 1 + (((((C / 100) % 4) * 5) + G) % 7);
185 crm_trace(
"YY=%d, C=%d, G=%d", YY, C, G);
186 crm_trace(
"January 1 %.4d: %d", year, jan1);
211static int month_days[13] = {
212 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29
226 if ((month < 1) || (month > 12)) {
232 return month_days[month - 1];
238 gboolean is_leap = FALSE;
243 if (year % 100 == 0 && year % 400 != 0) {
250get_ordinal_days(uint32_t y, uint32_t m, uint32_t d)
254 for (lpc = 1; lpc < m; lpc++) {
262 int line,
const char *prefix,
const crm_time_t *date_time,
269 (prefix? prefix :
""), (prefix?
": " :
""), date_s);
272 (prefix? prefix :
""), (prefix?
": " :
""), date_s);
278crm_time_get_sec(
int sec, uint32_t *h, uint32_t *m, uint32_t *s)
280 uint32_t hours, minutes, seconds;
282 seconds = QB_ABS(sec);
287 minutes = seconds / 60;
288 seconds -= 60 * minutes;
290 crm_trace(
"%d == %.2" PRIu32
":%.2" PRIu32
":%.2" PRIu32,
291 sec, hours, minutes, seconds);
302 crm_time_get_sec(dt->seconds, h, m, s);
311 crm_time_get_sec(dt->seconds, h, m, &s);
320 long long in_seconds = 0;
326 utc = crm_get_utc_time(dt);
331 for (lpc = 1; lpc < utc->years; lpc++) {
332 long long dmax = year_days(lpc);
344 if (utc->months > 0) {
345 in_seconds +=
DAY_SECONDS * 30 * (
long long) (utc->months);
349 in_seconds +=
DAY_SECONDS * (
long long) (utc->days - 1);
351 in_seconds += utc->seconds;
357#define EPOCH_SECONDS 62135596800ULL
372 for (months = 1; months <= 12 && days > 0; months++) {
382 }
else if (dt->months) {
393 crm_trace(
"%.4d-%.3d -> %.4d-%.2d-%.2d", dt->years, dt->days, dt->years, months, days);
420 h = dt->days + jan1 - 1;
421 *d = 1 + ((h - 1) % 7);
424 if (dt->days <= (8 - jan1) && jan1 > 4) {
426 year_num = dt->years - 1;
430 year_num = dt->years;
434 if (year_num == dt->years) {
435 int dmax = year_days(year_num);
436 int correction = 4 - *d;
438 if ((dmax - dt->days) < correction) {
439 crm_trace(
"year++, jan1=%d, i=%d vs. %d", jan1, dmax - dt->days, correction);
440 year_num = dt->years + 1;
446 if (year_num == dt->years) {
447 int j = dt->days + (7 - *d) + (jan1 - 1);
456 crm_trace(
"Converted %.4d-%.3d to %.4" PRIu32
"-W%.2" PRIu32
"-%" PRIu32,
457 dt->years, dt->days, *y, *w, *d);
474sec_usec_as_string(
long long sec,
int usec,
char *buf,
size_t *offset)
476 *offset += snprintf(buf + *offset,
DATE_MAX - *offset,
"%s%lld.%06d",
477 ((sec == 0) && (usec < 0))?
"-" :
"",
491crm_duration_as_string(
const crm_time_t *dt,
int usec,
bool show_usec,
499 offset += snprintf(
result + offset,
DATE_MAX - offset,
"%4d year%s ",
503 offset += snprintf(
result + offset,
DATE_MAX - offset,
"%2d month%s ",
507 offset += snprintf(
result + offset,
DATE_MAX - offset,
"%2d day%s ",
512 if ((offset == 0) || (dt->seconds != 0) || (show_usec && (usec != 0))) {
514 sec_usec_as_string(dt->seconds, usec,
result, &offset);
519 offset += snprintf(
result + offset,
DATE_MAX - offset,
" second%s",
524 if (QB_ABS(dt->seconds) >= 60) {
528 uint32_t u = QB_ABS(usec);
529 bool print_sec_component =
false;
531 crm_time_get_sec(dt->seconds, &h, &m, &s);
532 print_sec_component = ((s != 0) || (show_usec && (u != 0)));
539 ((m != 0) || print_sec_component)?
" " :
"");
545 print_sec_component?
" " :
"");
548 if (print_sec_component) {
550 sec_usec_as_string(s, u,
result, &offset);
555 offset += snprintf(
result + offset,
DATE_MAX - offset,
" second%s",
582 strcpy(
result,
"<undefined time>");
599 long long seconds = 0;
608 sec_usec_as_string(seconds, usec,
result, &offset);
618 utc = crm_get_utc_time(dt);
632 "%" PRIu32
"-W%.2" PRIu32
"-%" PRIu32,
642 "%" PRIu32
"-%.3" PRIu32, y, d);
652 "%.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32,
659 uint32_t h = 0, m = 0, s = 0;
667 "%.2" PRIu32
":%.2" PRIu32
":%.2" PRIu32,
672 ".%06" PRIu32, QB_ABS(usec));
677 && (dt->offset != 0)) {
678 crm_time_get_sec(dt->offset, &h, &m, &s);
680 " %c%.2" PRIu32
":%.2" PRIu32,
681 ((dt->offset < 0)?
'-' :
'+'), h, m);
719crm_time_parse_sec(
const char *time_str,
int *
result)
729 rc = sscanf(time_str,
"%" SCNu32
":%" SCNu32
":%" SCNu32,
730 &hour, &minute, &second);
732 rc = sscanf(time_str,
"%2" SCNu32
"%2" SCNu32
"%2" SCNu32,
733 &hour, &minute, &second);
736 crm_err(
"%s is not a valid ISO 8601 time specification", time_str);
741 crm_trace(
"Got valid time: %.2" PRIu32
":%.2" PRIu32
":%.2" PRIu32,
742 hour, minute, second);
744 if ((hour == 24) && (minute == 0) && (second == 0)) {
746 }
else if (hour >= 24) {
747 crm_err(
"%s is not a valid ISO 8601 time specification "
748 "because %" PRIu32
" is not a valid hour", time_str, hour);
753 crm_err(
"%s is not a valid ISO 8601 time specification "
754 "because %" PRIu32
" is not a valid minute", time_str, minute);
759 crm_err(
"%s is not a valid ISO 8601 time specification "
760 "because %" PRIu32
" is not a valid second", time_str, second);
770crm_time_parse_offset(
const char *offset_str,
int *offset)
774 if (offset_str == NULL) {
776#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
777 time_t now = time(NULL);
778 struct tm *now_tm = localtime(&now);
783 if (h_offset < 0 && m_offset < 0) {
784 m_offset = 0 - m_offset;
790 if (offset_str[0] ==
'Z') {
796 if ((offset_str[0] ==
'+') || (offset_str[0] ==
'-')
797 || isdigit((
int)offset_str[0])) {
799 gboolean negate = FALSE;
801 if (offset_str[0] ==
'+') {
803 }
else if (offset_str[0] ==
'-') {
807 if (crm_time_parse_sec(offset_str, offset) == FALSE) {
811 *offset = 0 - *offset;
828crm_time_parse(
const char *time_str,
crm_time_t *a_time)
831 char *offset_s = NULL;
836 if (crm_time_parse_sec(time_str, &(a_time->seconds)) == FALSE) {
839 offset_s = strstr(time_str,
"Z");
840 if (offset_s == NULL) {
841 offset_s = strstr(time_str,
" ");
843 while (isspace(offset_s[0])) {
850 if (crm_time_parse_offset(offset_s, &(a_time->offset)) == FALSE) {
853 crm_time_get_sec(a_time->offset, &h, &m, &s);
854 crm_trace(
"Got tz: %c%2." PRIu32
":%.2" PRIu32,
855 (a_time->offset < 0)?
'-' :
'+', h, m);
875parse_date(
const char *date_str)
877 const char *time_s = NULL;
886 if (pcmk__str_empty(date_str)) {
887 crm_err(
"No ISO 8601 date/time specification given");
891 if ((date_str[0] ==
'T') || (date_str[2] ==
':')) {
894 if (date_str[0] ==
'T') {
895 time_s = date_str + 1;
905 && ((date_str[5] ==
'\0')
906 || (date_str[5] ==
'/')
907 || isspace(date_str[5]))) {
915 rc = sscanf(date_str,
"%d-%d-%d", &year, &month, &day);
918 rc = sscanf(date_str,
"%4d%2d%2d", &year, &month, &day);
922 crm_err(
"'%s' is not a valid ISO 8601 date/time specification "
923 "because '%d' is not a valid month", date_str, month);
926 crm_err(
"'%s' is not a valid ISO 8601 date/time specification "
927 "because '%d' is not a valid day of the month",
932 dt->days = get_ordinal_days(year, month, day);
933 crm_trace(
"Parsed Gregorian date '%.4d-%.3d' from date string '%s'",
934 year, dt->days, date_str);
940 rc = sscanf(date_str,
"%d-%d", &year, &day);
942 if (day > year_days(year)) {
943 crm_err(
"'%s' is not a valid ISO 8601 date/time specification "
944 "because '%d' is not a valid day of the year (max %d)",
945 date_str, day, year_days(year));
948 crm_trace(
"Parsed ordinal year %d and days %d from date string '%s'",
949 year, day, date_str);
956 rc = sscanf(date_str,
"%d-W%d-%d", &year, &week, &day);
959 crm_err(
"'%s' is not a valid ISO 8601 date/time specification "
960 "because '%d' is not a valid week of the year (max %d)",
963 }
else if (day < 1 || day > 7) {
964 crm_err(
"'%s' is not a valid ISO 8601 date/time specification "
965 "because '%d' is not a valid day of the week",
981 crm_trace(
"Got year %d (Jan 1 = %d), week %d, and day %d from date string '%s'",
982 year, jan1, week, day, date_str);
998 crm_err(
"'%s' is not a valid ISO 8601 date/time specification", date_str);
1003 if (time_s == NULL) {
1004 time_s = date_str + strspn(date_str,
"0123456789-W");
1005 if ((time_s[0] ==
' ') || (time_s[0] ==
'T')) {
1011 if ((time_s != NULL) && (crm_time_parse(time_s, dt) == FALSE)) {
1017 crm_err(
"'%s' is not a valid ISO 8601 date/time specification",
1034parse_int(
const char *str,
int field_width,
int upper_bound,
int *
result)
1038 int intermediate = 0;
1039 gboolean fraction = FALSE;
1040 gboolean negate = FALSE;
1047 if (str[offset] ==
'T') {
1051 if (str[offset] ==
'.' || str[offset] ==
',') {
1055 }
else if (str[offset] ==
'-') {
1058 }
else if (str[offset] ==
'+' || str[offset] ==
':') {
1062 for (; (fraction || lpc < field_width) && isdigit((
int)str[offset]); lpc++) {
1064 intermediate = (str[offset] -
'0') / (10 ^ lpc);
1067 intermediate = str[offset] -
'0';
1075 }
else if (upper_bound > 0 && *
result > upper_bound) {
1082 crm_trace(
"Found int: %d. Stopped at str[%d]='%c'", *
result, lpc, str[lpc]);
1102 gboolean is_time = FALSE;
1105 if (pcmk__str_empty(period_s)) {
1106 crm_err(
"No ISO 8601 time duration given");
1109 if (period_s[0] !=
'P') {
1110 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1111 "because it does not start with a 'P'", period_s);
1114 if ((period_s[1] ==
'\0') || isspace(period_s[1])) {
1115 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1116 "because nothing follows 'P'", period_s);
1121 diff->duration = TRUE;
1123 for (
const char *current = period_s + 1;
1124 current[0] && (current[0] !=
'/') && !isspace(current[0]);
1129 if (current[0] ==
'T') {
1139 rc = parse_int(current, 10, 0, &an_int);
1141 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1142 "because no integer at '%s'", period_s, current);
1148 switch (current[0]) {
1150 diff->years = an_int;
1155 diff->seconds += an_int * 60;
1157 diff->months = an_int;
1161 diff->days += an_int * 7;
1164 diff->days += an_int;
1170 diff->seconds += an_int;
1173 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1174 "because no units after %d", period_s, an_int);
1177 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1178 "because '%c' is not a valid time unit",
1179 period_s, current[0]);
1185 crm_err(
"'%s' is not a valid ISO 8601 time duration "
1186 "because no amounts and units given", period_s);
1210 const char *original = period_str;
1213 if (pcmk__str_empty(period_str)) {
1214 crm_err(
"No ISO 8601 time period given");
1221 if (period_str[0] ==
'P') {
1223 if (period->
diff == NULL) {
1227 period->
start = parse_date(period_str);
1228 if (period->
start == NULL) {
1233 period_str = strstr(original,
"/");
1236 if (period_str[0] ==
'P') {
1237 if (period->
diff != NULL) {
1238 crm_err(
"'%s' is not a valid ISO 8601 time period "
1239 "because it has two durations",
1244 if (period->
diff == NULL) {
1248 period->
end = parse_date(period_str);
1249 if (period->
end == NULL) {
1254 }
else if (period->
diff != NULL) {
1260 crm_err(
"'%s' is not a valid ISO 8601 time period "
1261 "because it has no duration or ending time",
1266 if (period->
start == NULL) {
1269 }
else if (period->
end == NULL) {
1274 crm_err(
"'%s' is not a valid ISO 8601 time period "
1275 "because the start is invalid", period_str);
1279 crm_err(
"'%s' is not a valid ISO 8601 time period "
1280 "because the end is invalid", period_str);
1315 target->years = source->years;
1316 target->days = source->days;
1317 target->months = source->months;
1318 target->seconds = source->seconds;
1319 target->offset = source->offset;
1339 target->duration = FALSE;
1341 if (source->tm_year > 0) {
1343 target->years = 1900 + source->tm_year;
1346 if (source->tm_yday >= 0) {
1348 target->days = 1 + source->tm_yday;
1351 if (source->tm_hour >= 0) {
1354 if (source->tm_min >= 0) {
1355 target->seconds += 60 * source->tm_min;
1357 if (source->tm_sec >= 0) {
1358 target->seconds += source->tm_sec;
1364 crm_trace(
"Time offset is %lds (%.2d:%.2d)",
1365 GMTOFF(source), h_offset, m_offset);
1368 target->offset += 60 * m_offset;
1374 ha_set_tm_time(
target, localtime(source));
1387 if ((
target != NULL) && (source != NULL)
1426 if ((dt == NULL) || (value == NULL)) {
1433 utc = crm_get_utc_time(value);
1439 answer->years += utc->years;
1460 switch (component) {
1500 switch (component) {
1546 if ((t == NULL) || (attr == NULL) || (add == NULL)) {
1559 if ((value < INT_MIN) || (value > INT_MAX)) {
1564 add(t, (
int) value);
1575 if ((dt == NULL) || (value == NULL)) {
1580 utc = crm_get_utc_time(value);
1585 answer = crm_get_utc_time(dt);
1586 if (answer == NULL) {
1590 answer->duration = TRUE;
1592 answer->years -= utc->years;
1593 if(utc->months != 0) {
1609 if ((dt == NULL) || (value == NULL)) {
1614 utc = crm_get_utc_time(value);
1620 answer->years -= utc->years;
1621 if(utc->months != 0) {
1642 && (dt->days > 0) && (dt->days <= year_days(dt->years))
1643 && (dt->seconds >= 0) && (dt->seconds <
DAY_SECONDS);
1646#define do_cmp_field(l, r, field) \
1648 if(l->field > r->field) { \
1649 crm_trace("%s: %d > %d", \
1650 #field, l->field, r->field); \
1652 } else if(l->field < r->field) { \
1653 crm_trace("%s: %d < %d", \
1654 #field, l->field, r->field); \
1666 if ((t1 == NULL) && (t2 == NULL)) {
1668 }
else if (t1 == NULL) {
1670 }
else if (t2 == NULL) {
1694 crm_trace(
"Adding %d seconds to %d (max=%d)",
1696 a_time->seconds += extra;
1701 if (a_time->seconds < 0) {
1712 int lower_bound = 1;
1715 crm_trace(
"Adding %d days to %.4d-%.3d", extra, a_time->years, a_time->days);
1717 a_time->days += extra;
1718 while (a_time->days > ydays) {
1720 a_time->days -= ydays;
1724 if(a_time->duration) {
1728 while (a_time->days < lower_bound) {
1738 uint32_t y, m, d, dmax;
1741 crm_trace(
"Adding %d months to %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32,
1745 for (lpc = extra; lpc > 0; lpc--) {
1753 for (lpc = -extra; lpc > 0; lpc--) {
1768 crm_trace(
"Calculated %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1771 a_time->days = get_ordinal_days(y, m, d);
1774 crm_trace(
"Got %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1798 a_time->years += extra;
1805 .tm_year = source->years - 1900,
1806 .tm_mday = source->days,
1807 .tm_sec = source->seconds % 60,
1808 .tm_min = ( source->seconds / 60 ) % 60,
1813 .tm_gmtoff = source->offset
1836 if (hr_dt == NULL) {
1842 .months = dt->months,
1844 .seconds = dt->seconds,
1845 .offset = dt->offset,
1846 .duration = dt->duration
1858 .years = hr_dt->
years,
1860 .days = hr_dt->
days,
1882 qb_util_timespec_from_epoch_get(&tv);
1883 if (epoch != NULL) {
1889 hr->
useconds = tv.tv_nsec / QB_TIME_NS_IN_USEC;
1899 if (date_time == NULL) {
1904 dt = parse_date(date_time);
1920#define DATE_LEN_MAX 128
1921 const char *mark_s = NULL;
1922 int scanned_pos = 0;
1923 int printed_pos = 0;
1925 size_t date_len = 0;
1926 int nano_digits = 0;
1928 char nano_s[10] = {
'\0', };
1930 char nanofmt_s[5] =
"%";
1931 char *tmp_fmt_s = NULL;
1933 struct tm tm = { 0, };
1940 ha_get_tm_time(&tm, &dt);
1941 sprintf(nano_s,
"%06d000", hr_dt->
useconds);
1943 while ((format[scanned_pos]) !=
'\0') {
1944 mark_s = strchr(&format[scanned_pos],
'%');
1948 fmt_pos = mark_s - format;
1949 while ((format[fmt_pos+fmt_len] !=
'\0') &&
1950 (format[fmt_pos+fmt_len] >=
'0') &&
1951 (format[fmt_pos+fmt_len] <=
'9')) {
1954 scanned_pos = fmt_pos + fmt_len + 1;
1955 if (format[fmt_pos+fmt_len] ==
'N') {
1956 nano_digits = atoi(&format[fmt_pos+1]);
1957 nano_digits = (nano_digits > 6)?6:nano_digits;
1958 nano_digits = (nano_digits < 0)?0:nano_digits;
1959 sprintf(&nanofmt_s[1],
".%ds", nano_digits);
1961 if (format[scanned_pos] !=
'\0') {
1964 fmt_pos = scanned_pos;
1967 scanned_pos = strlen(format);
1968 fmt_pos = scanned_pos;
1970 tmp_fmt_s = strndup(&format[printed_pos], fmt_pos - printed_pos);
1971#ifdef HAVE_FORMAT_NONLITERAL
1972#pragma GCC diagnostic push
1973#pragma GCC diagnostic ignored "-Wformat-nonliteral"
1975 date_len += strftime(&date_s[date_len],
DATE_LEN_MAX - date_len,
1977#ifdef HAVE_FORMAT_NONLITERAL
1978#pragma GCC diagnostic pop
1980 printed_pos = scanned_pos;
1983#ifdef HAVE_FORMAT_NONLITERAL
1984#pragma GCC diagnostic push
1985#pragma GCC diagnostic ignored "-Wformat-nonliteral"
1987 date_len += snprintf(&date_s[date_len],
DATE_LEN_MAX - date_len,
1989#ifdef HAVE_FORMAT_NONLITERAL
1990#pragma GCC diagnostic pop
1996 return (date_len == 0)?NULL:strdup(date_s);
2016 time_t epoch_time = (source == NULL)? time(NULL) : *source;
2048 struct timespec tmp_ts;
2053 qb_util_timespec_from_epoch_get(&tmp_ts);
2057 time_as_string_common(&dt, ts->tv_nsec / QB_TIME_NS_IN_USEC,
flags,
result);
2075#define MS_IN_S (1000)
2076#define MS_IN_M (MS_IN_S * 60)
2077#define MS_IN_H (MS_IN_M * 60)
2078#define MS_IN_D (MS_IN_H * 24)
2079#define MAXSTR sizeof("..d..h..m..s...ms")
2085 offset += snprintf(str + offset,
MAXSTR - offset,
"%ud",
2090 offset += snprintf(str + offset,
MAXSTR - offset,
"%uh",
2095 offset += snprintf(str + offset,
MAXSTR - offset,
"%um",
2102 offset += snprintf(str + offset,
MAXSTR - offset,
"%u",
2105 if (interval_ms > 0) {
2106 offset += snprintf(str + offset,
MAXSTR - offset,
".%03u",
2109 (void) snprintf(str + offset,
MAXSTR - offset,
"s");
2111 }
else if (interval_ms > 0) {
2112 (void) snprintf(str + offset,
MAXSTR - offset,
"%ums", interval_ms);
2114 }
else if (str[0] ==
'\0') {
#define pcmk__assert_alloc(nmemb, size)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define HAVE_STRUCT_TM_TM_GMTOFF
crm_time_t * crm_time_new(const char *date_time)
crm_time_t * pcmk__copy_timet(time_t source)
void crm_time_set_timet(crm_time_t *target, const time_t *source)
crm_time_t * crm_time_subtract(const crm_time_t *dt, const crm_time_t *value)
const char * pcmk__time_component_attr(enum pcmk__time_component component)
char * pcmk__time_format_hr(const char *format, const pcmk__time_hr_t *hr_dt)
void(* component_fn_t)(crm_time_t *, int)
void crm_time_set(crm_time_t *target, const crm_time_t *source)
void crm_time_add_months(crm_time_t *a_time, int extra)
pcmk__time_hr_t * pcmk__time_hr_convert(pcmk__time_hr_t *target, const crm_time_t *dt)
char * pcmk__epoch2str(const time_t *source, uint32_t flags)
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt)
crm_time_period_t * crm_time_parse_period(const char *period_str)
Parse a time period from an ISO 8601 interval specification.
int crm_time_january1_weekday(int year)
void crm_time_free(crm_time_t *dt)
void crm_time_free_period(crm_time_period_t *period)
Free a dynamically allocated time period object.
int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d)
crm_time_t * pcmk_copy_time(const crm_time_t *source)
void pcmk__set_time_if_earlier(crm_time_t *target, const crm_time_t *source)
int crm_time_days_in_month(int month, int year)
Return number of days in given month of given year.
int pcmk__add_time_from_xml(crm_time_t *t, enum pcmk__time_component component, const xmlNode *xml)
const char * pcmk__readable_interval(guint interval_ms)
void crm_time_add_minutes(crm_time_t *a_time, int extra)
pcmk__time_hr_t * pcmk__time_hr_new(const char *date_time)
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
void crm_time_add_seconds(crm_time_t *a_time, int extra)
Add a given number of seconds to a date/time or duration.
int crm_time_weeks_in_year(int year)
char * crm_time_as_string(const crm_time_t *dt, int flags)
Get a string representation of a crm_time_t object.
crm_time_t * crm_time_calculate_duration(const crm_time_t *dt, const crm_time_t *value)
#define valid_sec_usec(sec, usec)
bool crm_time_check(const crm_time_t *dt)
Check whether a time object represents a sensible date/time.
void pcmk__time_set_hr_dt(crm_time_t *target, const pcmk__time_hr_t *hr_dt)
bool crm_time_leapyear(int year)
crm_time_t * crm_time_add(const crm_time_t *dt, const crm_time_t *value)
long long crm_time_get_seconds(const crm_time_t *dt)
int crm_time_get_timezone(const crm_time_t *dt, uint32_t *h, uint32_t *m)
void crm_time_add_days(crm_time_t *a_time, int extra)
void crm_time_add_weeks(crm_time_t *a_time, int extra)
crm_time_t * crm_time_parse_duration(const char *period_s)
Parse a time duration from an ISO 8601 duration specification.
void pcmk__time_hr_free(pcmk__time_hr_t *hr_dt)
void crm_time_add_years(crm_time_t *a_time, int extra)
int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, uint32_t *s)
char * pcmk__timespec2str(const struct timespec *ts, uint32_t flags)
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
pcmk__time_hr_t * pcmk__time_hr_now(time_t *epoch)
int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, uint32_t *d)
int crm_time_compare(const crm_time_t *a, const crm_time_t *b)
void crm_time_add_hours(crm_time_t *a_time, int extra)
#define do_cmp_field(l, r, field)
void crm_time_log_alias(int log_level, const char *file, const char *function, int line, const char *prefix, const crm_time_t *date_time, int flags)
int crm_time_get_isoweek(const crm_time_t *dt, uint32_t *y, uint32_t *w, uint32_t *d)
#define crm_time_log_duration
#define crm_time_log_timeofday
#define crm_time_log_with_timezone
#define crm_time_log_date
struct crm_time_s crm_time_t
#define crm_time_log(level, prefix, dt, flags)
struct pcmk__time_us pcmk__time_hr_t
#define CRM_CHECK(expr, failure_action)
#define crm_err(fmt, args...)
#define do_crm_log_alias(level, file, function, line, fmt, args...)
Log a message as if it came from a different code location.
#define crm_trace(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__VALUE_EPOCH
pcmk__action_result_t result
#define pcmk__plural_s(i)
char * pcmk__trim(char *str)
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
#define pcmk__str_copy(str)