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)))) 79 static 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);
211 static 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) {
250 get_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);
278 crm_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);
474 sec_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))?
"-" :
"",
491 crm_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);
719 crm_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);
770 crm_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;
828 crm_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);
875 parse_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')
892 || ((strlen(date_str) > 2) && (date_str[2] ==
':'))) {
895 if (date_str[0] ==
'T') {
896 time_s = date_str + 1;
906 && ((date_str[5] ==
'\0')
907 || (date_str[5] ==
'/')
908 || isspace(date_str[5]))) {
916 rc = sscanf(date_str,
"%d-%d-%d", &year, &month, &day);
919 rc = sscanf(date_str,
"%4d%2d%2d", &year, &month, &day);
923 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 924 "because '%d' is not a valid month", date_str, month);
927 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 928 "because '%d' is not a valid day of the month",
933 dt->days = get_ordinal_days(year, month, day);
934 crm_trace(
"Parsed Gregorian date '%.4d-%.3d' from date string '%s'",
935 year, dt->days, date_str);
941 rc = sscanf(date_str,
"%d-%d", &year, &day);
943 if (day > year_days(year)) {
944 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 945 "because '%d' is not a valid day of the year (max %d)",
946 date_str, day, year_days(year));
949 crm_trace(
"Parsed ordinal year %d and days %d from date string '%s'",
950 year, day, date_str);
957 rc = sscanf(date_str,
"%d-W%d-%d", &year, &week, &day);
960 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 961 "because '%d' is not a valid week of the year (max %d)",
964 }
else if (day < 1 || day > 7) {
965 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 966 "because '%d' is not a valid day of the week",
982 crm_trace(
"Got year %d (Jan 1 = %d), week %d, and day %d from date string '%s'",
983 year, jan1, week, day, date_str);
999 crm_err(
"'%s' is not a valid ISO 8601 date/time specification", date_str);
1004 if (time_s == NULL) {
1005 time_s = date_str + strspn(date_str,
"0123456789-W");
1006 if ((time_s[0] ==
' ') || (time_s[0] ==
'T')) {
1012 if ((time_s != NULL) && (crm_time_parse(time_s, dt) == FALSE)) {
1018 crm_err(
"'%s' is not a valid ISO 8601 date/time specification",
1032 parse_int(
const char *str,
int *
result)
1035 int offset = (str[0] ==
'T')? 1 : 0;
1036 bool negate =
false;
1041 switch (str[offset]) {
1060 for (lpc = 0; (lpc < 10) && isdigit(str[offset]); lpc++) {
1061 const int digit = str[offset++] -
'0';
1063 if ((*
result * 10LL + digit) > INT_MAX) {
1071 return (lpc > 0)? offset : 0;
1088 gboolean is_time = FALSE;
1091 if (pcmk__str_empty(period_s)) {
1092 crm_err(
"No ISO 8601 time duration given");
1095 if (period_s[0] !=
'P') {
1096 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1097 "because it does not start with a 'P'", period_s);
1100 if ((period_s[1] ==
'\0') || isspace(period_s[1])) {
1101 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1102 "because nothing follows 'P'", period_s);
1108 for (
const char *current = period_s + 1;
1109 current[0] && (current[0] !=
'/') && !isspace(current[0]);
1114 if (current[0] ==
'T') {
1124 rc = parse_int(current, &an_int);
1126 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1127 "because no valid integer at '%s'", period_s, current);
1133 switch (current[0]) {
1135 diff->years = an_int;
1140 diff->months = an_int;
1143 }
else if ((diff->seconds + (an_int * 60LL)) > INT_MAX) {
1144 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1145 "because integer at '%s' is too large",
1146 period_s, current - rc);
1149 diff->seconds += an_int * 60;
1154 if ((diff->days + (an_int * 7LL)) > INT_MAX) {
1155 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1156 "because integer at '%s' is too large",
1157 period_s, current - rc);
1160 diff->days += an_int * 7;
1165 if ((diff->days + (
long long) an_int) > INT_MAX) {
1166 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1167 "because integer at '%s' is too large",
1168 period_s, current - rc);
1171 diff->days += an_int;
1176 if ((diff->seconds + ((
long long) an_int *
HOUR_SECONDS))
1178 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1179 "because integer at '%s' is too large",
1180 period_s, current - rc);
1188 if ((diff->seconds + (
long long) an_int) > INT_MAX) {
1189 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1190 "because integer at '%s' is too large",
1191 period_s, current - rc);
1194 diff->seconds += an_int;
1199 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1200 "because no units after %d", period_s, an_int);
1204 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1205 "because '%c' is not a valid time unit",
1206 period_s, current[0]);
1212 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1213 "because no amounts and units given", period_s);
1217 diff->duration = TRUE;
1239 const char *original = period_str;
1242 if (pcmk__str_empty(period_str)) {
1243 crm_err(
"No ISO 8601 time period given");
1250 if (period_str[0] ==
'P') {
1252 if (period->
diff == NULL) {
1256 period->
start = parse_date(period_str);
1257 if (period->
start == NULL) {
1262 period_str = strstr(original,
"/");
1265 if (period_str[0] ==
'P') {
1266 if (period->
diff != NULL) {
1267 crm_err(
"'%s' is not a valid ISO 8601 time period " 1268 "because it has two durations",
1273 if (period->
diff == NULL) {
1277 period->
end = parse_date(period_str);
1278 if (period->
end == NULL) {
1283 }
else if (period->
diff != NULL) {
1289 crm_err(
"'%s' is not a valid ISO 8601 time period " 1290 "because it has no duration or ending time",
1295 if (period->
start == NULL) {
1298 }
else if (period->
end == NULL) {
1303 crm_err(
"'%s' is not a valid ISO 8601 time period " 1304 "because the start is invalid", period_str);
1308 crm_err(
"'%s' is not a valid ISO 8601 time period " 1309 "because the end is invalid", period_str);
1344 target->years = source->years;
1345 target->days = source->days;
1346 target->months = source->months;
1347 target->seconds = source->seconds;
1348 target->offset = source->offset;
1368 target->duration = FALSE;
1370 if (source->tm_year > 0) {
1372 target->years = 1900 + source->tm_year;
1375 if (source->tm_yday >= 0) {
1377 target->days = 1 + source->tm_yday;
1380 if (source->tm_hour >= 0) {
1383 if (source->tm_min >= 0) {
1384 target->seconds += 60 * source->tm_min;
1386 if (source->tm_sec >= 0) {
1387 target->seconds += source->tm_sec;
1393 crm_trace(
"Time offset is %lds (%.2d:%.2d)",
1394 GMTOFF(source), h_offset, m_offset);
1397 target->offset += 60 * m_offset;
1403 ha_set_tm_time(
target, localtime(source));
1416 if ((
target != NULL) && (source != NULL)
1455 if ((dt == NULL) || (value == NULL)) {
1462 utc = crm_get_utc_time(value);
1468 answer->years += utc->years;
1489 switch (component) {
1529 switch (component) {
1575 if ((t == NULL) || (attr == NULL) || (add == NULL)) {
1588 if ((value < INT_MIN) || (value > INT_MAX)) {
1593 add(t, (
int) value);
1604 if ((dt == NULL) || (value == NULL)) {
1609 utc = crm_get_utc_time(value);
1614 answer = crm_get_utc_time(dt);
1615 if (answer == NULL) {
1619 answer->duration = TRUE;
1621 answer->years -= utc->years;
1622 if(utc->months != 0) {
1638 if ((dt == NULL) || (value == NULL)) {
1643 utc = crm_get_utc_time(value);
1649 answer->years -= utc->years;
1650 if(utc->months != 0) {
1671 && (dt->days > 0) && (dt->days <= year_days(dt->years))
1672 && (dt->seconds >= 0) && (dt->seconds <
DAY_SECONDS);
1675 #define do_cmp_field(l, r, field) \ 1677 if(l->field > r->field) { \ 1678 crm_trace("%s: %d > %d", \ 1679 #field, l->field, r->field); \ 1681 } else if(l->field < r->field) { \ 1682 crm_trace("%s: %d < %d", \ 1683 #field, l->field, r->field); \ 1695 if ((t1 == NULL) && (t2 == NULL)) {
1697 }
else if (t1 == NULL) {
1699 }
else if (t2 == NULL) {
1723 crm_trace(
"Adding %d seconds to %d (max=%d)",
1725 a_time->seconds += extra;
1730 if (a_time->seconds < 0) {
1741 int lower_bound = 1;
1744 crm_trace(
"Adding %d days to %.4d-%.3d", extra, a_time->years, a_time->days);
1746 a_time->days += extra;
1747 while (a_time->days > ydays) {
1749 a_time->days -= ydays;
1753 if(a_time->duration) {
1757 while (a_time->days < lower_bound) {
1767 uint32_t y, m, d, dmax;
1770 crm_trace(
"Adding %d months to %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32,
1774 for (lpc = extra; lpc > 0; lpc--) {
1782 for (lpc = -extra; lpc > 0; lpc--) {
1797 crm_trace(
"Calculated %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1800 a_time->days = get_ordinal_days(y, m, d);
1803 crm_trace(
"Got %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1827 a_time->years += extra;
1834 .tm_year = source->years - 1900,
1835 .tm_mday = source->days,
1836 .tm_sec = source->seconds % 60,
1837 .tm_min = ( source->seconds / 60 ) % 60,
1842 .tm_gmtoff = source->offset
1865 if (hr_dt == NULL) {
1871 .months = dt->months,
1873 .seconds = dt->seconds,
1874 .offset = dt->offset,
1875 .duration = dt->duration
1887 .years = hr_dt->
years,
1889 .days = hr_dt->
days,
1911 qb_util_timespec_from_epoch_get(&tv);
1912 if (epoch != NULL) {
1918 hr->
useconds = tv.tv_nsec / QB_TIME_NS_IN_USEC;
1928 if (date_time == NULL) {
1933 dt = parse_date(date_time);
1959 int scanned_pos = 0;
1960 int printed_pos = 0;
1961 size_t date_len = 0;
1963 char nano_s[10] = {
'\0', };
1964 char date_s[128] = {
'\0', };
1966 struct tm tm = { 0, };
1969 if (format == NULL) {
1973 ha_get_tm_time(&tm, &dt);
1974 sprintf(nano_s,
"%06d000", hr_dt->
useconds);
1976 while (format[scanned_pos] !=
'\0') {
1978 int nano_digits = 0;
1979 char *tmp_fmt_s = NULL;
1983 const char *mark_s = strchr(&format[scanned_pos],
'%');
1985 if (mark_s == NULL) {
1987 scanned_pos = strlen(format);
1988 fmt_pos = scanned_pos;
1991 fmt_pos = mark_s - format;
1994 scanned_pos = fmt_pos + 1;
1995 while (isdigit(format[scanned_pos])) {
1999 switch (format[scanned_pos]) {
2001 fmt_pos = scanned_pos;
2008 nano_digits = atoi(&format[fmt_pos + 1]);
2009 nano_digits = QB_MAX(nano_digits, 0);
2010 nano_digits = QB_MIN(nano_digits, 6);
2014 if (format[++scanned_pos] !=
'\0') {
2017 fmt_pos = scanned_pos;
2022 if (date_len >=
sizeof(date_s)) {
2026 tmp_fmt_s = strndup(&format[printed_pos], fmt_pos - printed_pos);
2027 #ifdef HAVE_FORMAT_NONLITERAL 2028 #pragma GCC diagnostic push 2029 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 2031 nbytes = strftime(&date_s[date_len],
sizeof(date_s) - date_len,
2033 #ifdef HAVE_FORMAT_NONLITERAL 2034 #pragma GCC diagnostic pop 2041 printed_pos = scanned_pos;
2042 if (nano_digits != 0) {
2045 if (date_len >=
sizeof(date_s)) {
2048 nc = snprintf(&date_s[date_len],
sizeof(date_s) - date_len,
2049 "%.*s", nano_digits, nano_s);
2051 if ((nc < 0) || (nc == (
sizeof(date_s) - date_len))) {
2077 time_t epoch_time = (source == NULL)? time(NULL) : *source;
2109 struct timespec tmp_ts;
2114 qb_util_timespec_from_epoch_get(&tmp_ts);
2118 time_as_string_common(&dt, ts->tv_nsec / QB_TIME_NS_IN_USEC,
flags,
result);
2136 #define MS_IN_S (1000) 2137 #define MS_IN_M (MS_IN_S * 60) 2138 #define MS_IN_H (MS_IN_M * 60) 2139 #define MS_IN_D (MS_IN_H * 24) 2140 #define MAXSTR sizeof("..d..h..m..s...ms") 2146 offset += snprintf(str + offset,
MAXSTR - offset,
"%ud",
2151 offset += snprintf(str + offset,
MAXSTR - offset,
"%uh",
2156 offset += snprintf(str + offset,
MAXSTR - offset,
"%um",
2163 offset += snprintf(str + offset,
MAXSTR - offset,
"%u",
2166 if (interval_ms > 0) {
2167 offset += snprintf(str + offset,
MAXSTR - offset,
".%03u",
2170 (void) snprintf(str + offset,
MAXSTR - offset,
"s");
2172 }
else if (interval_ms > 0) {
2173 (void) snprintf(str + offset,
MAXSTR - offset,
"%ums", interval_ms);
2175 }
else if (str[0] ==
'\0') {
int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m, uint32_t *d)
#define CRM_CHECK(expr, failure_action)
void crm_time_set_timet(crm_time_t *target, const time_t *source)
bool crm_time_leapyear(int year)
int pcmk__add_time_from_xml(crm_time_t *t, enum pcmk__time_component component, const xmlNode *xml)
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)
void pcmk__time_hr_free(pcmk__time_hr_t *hr_dt)
#define crm_time_log_timeofday
crm_time_t * crm_time_new(const char *date_time)
void pcmk__set_time_if_earlier(crm_time_t *target, const crm_time_t *source)
struct crm_time_s crm_time_t
bool crm_time_check(const crm_time_t *dt)
Check whether a time object represents a sensible date/time.
void crm_time_add_minutes(crm_time_t *a_time, int extra)
crm_time_t * crm_time_calculate_duration(const crm_time_t *dt, const crm_time_t *value)
const char * pcmk__readable_interval(guint interval_ms)
void crm_time_add_weeks(crm_time_t *a_time, int extra)
int crm_time_get_timezone(const crm_time_t *dt, uint32_t *h, uint32_t *m)
char * pcmk__epoch2str(const time_t *source, uint32_t flags)
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt)
void crm_time_set(crm_time_t *target, const crm_time_t *source)
int crm_time_compare(const crm_time_t *a, const crm_time_t *b)
void crm_time_free(crm_time_t *dt)
#define do_cmp_field(l, r, field)
crm_time_t * pcmk__copy_timet(time_t source)
#define valid_sec_usec(sec, usec)
char * pcmk__timespec2str(const struct timespec *ts, uint32_t flags)
#define do_crm_log_alias(level, file, function, line, fmt, args...)
Log a message as if it came from a different code location.
crm_time_t * crm_time_add(const crm_time_t *dt, const crm_time_t *value)
#define crm_time_log_duration
pcmk__time_hr_t * pcmk__time_hr_now(time_t *epoch)
long long crm_time_get_seconds(const crm_time_t *dt)
pcmk__time_hr_t * pcmk__time_hr_new(const char *date_time)
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
struct pcmk__time_us pcmk__time_hr_t
void pcmk__time_set_hr_dt(crm_time_t *target, const pcmk__time_hr_t *hr_dt)
crm_time_period_t * crm_time_parse_period(const char *period_str)
Parse a time period from an ISO 8601 interval specification.
void crm_time_add_seconds(crm_time_t *a_time, int extra)
Add a given number of seconds to a date/time or duration.
crm_time_t * pcmk_copy_time(const crm_time_t *source)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
void crm_time_add_days(crm_time_t *a_time, int extra)
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d)
crm_time_t * crm_time_parse_duration(const char *period_s)
Parse a time duration from an ISO 8601 duration specification.
int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m, uint32_t *s)
void crm_time_add_hours(crm_time_t *a_time, int extra)
#define crm_time_log(level, prefix, dt, flags)
int crm_time_days_in_month(int month, int year)
Return number of days in given month of given year.
#define crm_time_log_with_timezone
const char * pcmk__time_component_attr(enum pcmk__time_component component)
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define pcmk__str_copy(str)
char * crm_time_as_string(const crm_time_t *dt, int flags)
Get a string representation of a crm_time_t object.
char * pcmk__time_format_hr(const char *format, const pcmk__time_hr_t *hr_dt)
crm_time_t * crm_time_subtract(const crm_time_t *dt, const crm_time_t *value)
int crm_time_get_isoweek(const crm_time_t *dt, uint32_t *y, uint32_t *w, uint32_t *d)
void crm_time_add_years(crm_time_t *a_time, int extra)
bool crm_time_is_defined(const crm_time_t *t)
Check whether a time object has been initialized yet.
#define HAVE_STRUCT_TM_TM_GMTOFF
pcmk__action_result_t result
#define crm_err(fmt, args...)
void crm_time_add_months(crm_time_t *a_time, int extra)
int crm_time_weeks_in_year(int year)
int crm_time_january1_weekday(int year)
#define pcmk__plural_s(i)
pcmk__time_hr_t * pcmk__time_hr_convert(pcmk__time_hr_t *target, const crm_time_t *dt)
void(* component_fn_t)(crm_time_t *, int)
char * pcmk__trim(char *str)
#define PCMK__VALUE_EPOCH
#define pcmk__assert_alloc(nmemb, size)
void crm_time_free_period(crm_time_period_t *period)
Free a dynamically allocated time period object.
#define crm_time_log_date