40 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 41 # define GMTOFF(tm) ((tm)->tm_gmtoff) 44 # define GMTOFF(tm) (-timezone+daylight) 47 #define HOUR_SECONDS (60 * 60) 48 #define DAY_SECONDS (HOUR_SECONDS * 24) 62 #define valid_sec_usec(sec, usec) \ 63 ((QB_ABS(usec) < QB_TIME_US_IN_SEC) \ 64 && (((sec) == 0) || ((usec) == 0) || (((sec) < 0) == ((usec) < 0)))) 76 static crm_time_t *parse_date(
const char *date_str);
89 utc->years = dt->years;
91 utc->seconds = dt->seconds;
98 utc->months = dt->months;
112 if (date_time == NULL) {
115 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);
630 "%" PRIu32
"-W%.2" PRIu32
"-%" PRIu32,
639 "%" PRIu32
"-%.3" PRIu32, y, d);
647 "%.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32,
654 uint32_t h = 0, m = 0, s = 0;
662 "%.2" PRIu32
":%.2" PRIu32
":%.2" PRIu32,
667 ".%06" PRIu32, QB_ABS(usec));
672 && (dt->offset != 0)) {
673 crm_time_get_sec(dt->offset, &h, &m, &s);
675 " %c%.2" PRIu32
":%.2" PRIu32,
676 ((dt->offset < 0)?
'-' :
'+'), h, m);
697 char *result_copy = NULL;
717 crm_time_parse_sec(
const char *time_str,
int *
result)
727 rc = sscanf(time_str,
"%" SCNu32
":%" SCNu32
":%" SCNu32,
728 &hour, &minute, &second);
730 rc = sscanf(time_str,
"%2" SCNu32
"%2" SCNu32
"%2" SCNu32,
731 &hour, &minute, &second);
734 crm_err(
"%s is not a valid ISO 8601 time specification", time_str);
739 crm_trace(
"Got valid time: %.2" PRIu32
":%.2" PRIu32
":%.2" PRIu32,
740 hour, minute, second);
742 if ((hour == 24) && (minute == 0) && (second == 0)) {
744 }
else if (hour >= 24) {
745 crm_err(
"%s is not a valid ISO 8601 time specification " 746 "because %" PRIu32
" is not a valid hour", time_str, hour);
751 crm_err(
"%s is not a valid ISO 8601 time specification " 752 "because %" PRIu32
" is not a valid minute", time_str, minute);
757 crm_err(
"%s is not a valid ISO 8601 time specification " 758 "because %" PRIu32
" is not a valid second", time_str, second);
768 crm_time_parse_offset(
const char *offset_str,
int *offset)
772 if (offset_str == NULL) {
774 #if defined(HAVE_STRUCT_TM_TM_GMTOFF) 775 time_t now = time(NULL);
776 struct tm *now_tm = localtime(&now);
781 if (h_offset < 0 && m_offset < 0) {
782 m_offset = 0 - m_offset;
788 if (offset_str[0] ==
'Z') {
794 if ((offset_str[0] ==
'+') || (offset_str[0] ==
'-')
795 || isdigit((
int)offset_str[0])) {
797 gboolean negate = FALSE;
799 if (offset_str[0] ==
'+') {
801 }
else if (offset_str[0] ==
'-') {
805 if (crm_time_parse_sec(offset_str, offset) == FALSE) {
809 *offset = 0 - *offset;
826 crm_time_parse(
const char *time_str,
crm_time_t *a_time)
829 char *offset_s = NULL;
834 if (crm_time_parse_sec(time_str, &(a_time->seconds)) == FALSE) {
837 offset_s = strstr(time_str,
"Z");
838 if (offset_s == NULL) {
839 offset_s = strstr(time_str,
" ");
841 while (isspace(offset_s[0])) {
848 if (crm_time_parse_offset(offset_s, &(a_time->offset)) == FALSE) {
851 crm_time_get_sec(a_time->offset, &h, &m, &s);
852 crm_trace(
"Got tz: %c%2." PRIu32
":%.2" PRIu32,
853 (a_time->offset < 0)?
'-' :
'+', h, m);
872 parse_date(
const char *date_str)
874 const char *time_s = NULL;
883 if (pcmk__str_empty(date_str)) {
884 crm_err(
"No ISO 8601 date/time specification given");
888 if ((date_str[0] ==
'T') || (date_str[2] ==
':')) {
891 if (date_str[0] ==
'T') {
892 time_s = date_str + 1;
901 if (!strncasecmp(
"epoch", date_str, 5)
902 && ((date_str[5] ==
'\0') || (date_str[5] ==
'/') || isspace(date_str[5]))) {
910 rc = sscanf(date_str,
"%d-%d-%d", &year, &month, &day);
913 rc = sscanf(date_str,
"%4d%2d%2d", &year, &month, &day);
917 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 918 "because '%d' is not a valid month", date_str, month);
921 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 922 "because '%d' is not a valid day of the month",
927 dt->days = get_ordinal_days(year, month, day);
928 crm_trace(
"Parsed Gregorian date '%.4d-%.3d' from date string '%s'",
929 year, dt->days, date_str);
935 rc = sscanf(date_str,
"%d-%d", &year, &day);
937 if (day > year_days(year)) {
938 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 939 "because '%d' is not a valid day of the year (max %d)",
940 date_str, day, year_days(year));
943 crm_trace(
"Parsed ordinal year %d and days %d from date string '%s'",
944 year, day, date_str);
951 rc = sscanf(date_str,
"%d-W%d-%d", &year, &week, &day);
954 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 955 "because '%d' is not a valid week of the year (max %d)",
958 }
else if (day < 1 || day > 7) {
959 crm_err(
"'%s' is not a valid ISO 8601 date/time specification " 960 "because '%d' is not a valid day of the week",
976 crm_trace(
"Got year %d (Jan 1 = %d), week %d, and day %d from date string '%s'",
977 year, jan1, week, day, date_str);
993 crm_err(
"'%s' is not a valid ISO 8601 date/time specification", date_str);
998 if (time_s == NULL) {
999 time_s = date_str + strspn(date_str,
"0123456789-W");
1000 if ((time_s[0] ==
' ') || (time_s[0] ==
'T')) {
1006 if ((time_s != NULL) && (crm_time_parse(time_s, dt) == FALSE)) {
1012 crm_err(
"'%s' is not a valid ISO 8601 date/time specification",
1029 parse_int(
const char *str,
int field_width,
int upper_bound,
int *
result)
1033 int intermediate = 0;
1034 gboolean fraction = FALSE;
1035 gboolean negate = FALSE;
1042 if (str[offset] ==
'T') {
1046 if (str[offset] ==
'.' || str[offset] ==
',') {
1050 }
else if (str[offset] ==
'-') {
1053 }
else if (str[offset] ==
'+' || str[offset] ==
':') {
1057 for (; (fraction || lpc < field_width) && isdigit((
int)str[offset]); lpc++) {
1059 intermediate = (str[offset] -
'0') / (10 ^ lpc);
1062 intermediate = str[offset] -
'0';
1070 }
else if (upper_bound > 0 && *
result > upper_bound) {
1077 crm_trace(
"Found int: %d. Stopped at str[%d]='%c'", *
result, lpc, str[lpc]);
1097 gboolean is_time = FALSE;
1100 if (pcmk__str_empty(period_s)) {
1101 crm_err(
"No ISO 8601 time duration given");
1104 if (period_s[0] !=
'P') {
1105 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1106 "because it does not start with a 'P'", period_s);
1109 if ((period_s[1] ==
'\0') || isspace(period_s[1])) {
1110 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1111 "because nothing follows 'P'", period_s);
1116 diff->duration = TRUE;
1118 for (
const char *current = period_s + 1;
1119 current[0] && (current[0] !=
'/') && !isspace(current[0]);
1124 if (current[0] ==
'T') {
1134 rc = parse_int(current, 10, 0, &an_int);
1136 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1137 "because no integer at '%s'", period_s, current);
1143 switch (current[0]) {
1145 diff->years = an_int;
1150 diff->seconds += an_int * 60;
1152 diff->months = an_int;
1156 diff->days += an_int * 7;
1159 diff->days += an_int;
1165 diff->seconds += an_int;
1168 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1169 "because no units after %d", period_s, an_int);
1172 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1173 "because '%c' is not a valid time unit",
1174 period_s, current[0]);
1180 crm_err(
"'%s' is not a valid ISO 8601 time duration " 1181 "because no amounts and units given", period_s);
1205 const char *original = period_str;
1208 if (pcmk__str_empty(period_str)) {
1209 crm_err(
"No ISO 8601 time period given");
1217 if (period_str[0] ==
'P') {
1219 if (period->
diff == NULL) {
1223 period->
start = parse_date(period_str);
1224 if (period->
start == NULL) {
1229 period_str = strstr(original,
"/");
1232 if (period_str[0] ==
'P') {
1233 if (period->
diff != NULL) {
1234 crm_err(
"'%s' is not a valid ISO 8601 time period " 1235 "because it has two durations",
1240 if (period->
diff == NULL) {
1244 period->
end = parse_date(period_str);
1245 if (period->
end == NULL) {
1250 }
else if (period->
diff != NULL) {
1256 crm_err(
"'%s' is not a valid ISO 8601 time period " 1257 "because it has no duration or ending time",
1262 if (period->
start == NULL) {
1265 }
else if (period->
end == NULL) {
1270 crm_err(
"'%s' is not a valid ISO 8601 time period " 1271 "because the start is invalid", period_str);
1275 crm_err(
"'%s' is not a valid ISO 8601 time period " 1276 "because the end is invalid", period_str);
1311 target->years = source->years;
1312 target->days = source->days;
1313 target->months = source->months;
1314 target->seconds = source->seconds;
1315 target->offset = source->offset;
1335 target->duration = FALSE;
1337 if (source->tm_year > 0) {
1339 target->years = 1900 + source->tm_year;
1342 if (source->tm_yday >= 0) {
1344 target->days = 1 + source->tm_yday;
1347 if (source->tm_hour >= 0) {
1350 if (source->tm_min >= 0) {
1351 target->seconds += 60 * source->tm_min;
1353 if (source->tm_sec >= 0) {
1354 target->seconds += source->tm_sec;
1360 crm_trace(
"Time offset is %lds (%.2d:%.2d)",
1361 GMTOFF(source), h_offset, m_offset);
1364 target->offset += 60 * m_offset;
1370 ha_set_tm_time(
target, localtime(source));
1405 if ((dt == NULL) || (value == NULL)) {
1412 utc = crm_get_utc_time(value);
1418 answer->years += utc->years;
1433 if ((dt == NULL) || (value == NULL)) {
1438 utc = crm_get_utc_time(value);
1443 answer = crm_get_utc_time(dt);
1444 if (answer == NULL) {
1448 answer->duration = TRUE;
1450 answer->years -= utc->years;
1451 if(utc->months != 0) {
1467 if ((dt == NULL) || (value == NULL)) {
1472 utc = crm_get_utc_time(value);
1478 answer->years -= utc->years;
1479 if(utc->months != 0) {
1500 && (dt->days > 0) && (dt->days <= year_days(dt->years))
1501 && (dt->seconds >= 0) && (dt->seconds <
DAY_SECONDS);
1504 #define do_cmp_field(l, r, field) \ 1506 if(l->field > r->field) { \ 1507 crm_trace("%s: %d > %d", \ 1508 #field, l->field, r->field); \ 1510 } else if(l->field < r->field) { \ 1511 crm_trace("%s: %d < %d", \ 1512 #field, l->field, r->field); \ 1524 if ((t1 == NULL) && (t2 == NULL)) {
1526 }
else if (t1 == NULL) {
1528 }
else if (t2 == NULL) {
1552 crm_trace(
"Adding %d seconds to %d (max=%d)",
1554 a_time->seconds += extra;
1559 if (a_time->seconds < 0) {
1570 int lower_bound = 1;
1573 crm_trace(
"Adding %d days to %.4d-%.3d", extra, a_time->years, a_time->days);
1575 a_time->days += extra;
1576 while (a_time->days > ydays) {
1578 a_time->days -= ydays;
1582 if(a_time->duration) {
1586 while (a_time->days < lower_bound) {
1596 uint32_t y, m, d, dmax;
1599 crm_trace(
"Adding %d months to %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32,
1603 for (lpc = extra; lpc > 0; lpc--) {
1611 for (lpc = -extra; lpc > 0; lpc--) {
1626 crm_trace(
"Calculated %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1629 a_time->days = get_ordinal_days(y, m, d);
1632 crm_trace(
"Got %.4" PRIu32
"-%.2" PRIu32
"-%.2" PRIu32, y, m, d);
1656 a_time->years += extra;
1663 .tm_year = source->years - 1900,
1664 .tm_mday = source->days,
1665 .tm_sec = source->seconds % 60,
1666 .tm_min = ( source->seconds / 60 ) % 60,
1671 .tm_gmtoff = source->offset
1697 .months = dt->months,
1699 .seconds = dt->seconds,
1700 .offset = dt->offset,
1701 .duration = dt->duration
1713 .years = hr_dt->
years,
1715 .days = hr_dt->
days,
1737 qb_util_timespec_from_epoch_get(&tv);
1738 if (epoch != NULL) {
1744 hr->
useconds = tv.tv_nsec / QB_TIME_NS_IN_USEC;
1754 if (date_time == NULL) {
1759 dt = parse_date(date_time);
1776 int max = 128, scanned_pos = 0, printed_pos = 0, fmt_pos = 0,
1777 date_len = 0, nano_digits = 0;
1778 char nano_s[10], date_s[max+1], nanofmt_s[5] =
"%", *tmp_fmt_s;
1786 ha_get_tm_time(&tm, &dt);
1787 sprintf(nano_s,
"%06d000", hr_dt->
useconds);
1789 while ((format[scanned_pos]) !=
'\0') {
1790 mark_s = strchr(&format[scanned_pos],
'%');
1794 fmt_pos = mark_s - format;
1795 while ((format[fmt_pos+fmt_len] !=
'\0') &&
1796 (format[fmt_pos+fmt_len] >=
'0') &&
1797 (format[fmt_pos+fmt_len] <=
'9')) {
1800 scanned_pos = fmt_pos + fmt_len + 1;
1801 if (format[fmt_pos+fmt_len] ==
'N') {
1802 nano_digits = atoi(&format[fmt_pos+1]);
1803 nano_digits = (nano_digits > 6)?6:nano_digits;
1804 nano_digits = (nano_digits < 0)?0:nano_digits;
1805 sprintf(&nanofmt_s[1],
".%ds", nano_digits);
1807 if (format[scanned_pos] !=
'\0') {
1810 fmt_pos = scanned_pos;
1813 scanned_pos = strlen(format);
1814 fmt_pos = scanned_pos;
1816 tmp_fmt_s = strndup(&format[printed_pos], fmt_pos - printed_pos);
1817 #ifdef HAVE_FORMAT_NONLITERAL 1818 #pragma GCC diagnostic push 1819 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 1821 date_len += strftime(&date_s[date_len], max-date_len, tmp_fmt_s, &tm);
1822 #ifdef HAVE_FORMAT_NONLITERAL 1823 #pragma GCC diagnostic pop 1825 printed_pos = scanned_pos;
1828 #ifdef HAVE_FORMAT_NONLITERAL 1829 #pragma GCC diagnostic push 1830 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 1832 date_len += snprintf(&date_s[date_len], max-date_len,
1834 #ifdef HAVE_FORMAT_NONLITERAL 1835 #pragma GCC diagnostic pop 1841 return (date_len == 0)?NULL:strdup(date_s);
1860 time_t epoch_time = (source == NULL)? time(NULL) : *source;
1864 const char *buf =
pcmk__trim(ctime(&epoch_time));
1899 struct timespec tmp_ts;
1902 char *result_copy = NULL;
1905 qb_util_timespec_from_epoch_get(&tmp_ts);
1909 time_as_string_common(&dt, ts->tv_nsec / QB_TIME_NS_IN_USEC,
flags,
result);
1928 #define MS_IN_S (1000) 1929 #define MS_IN_M (MS_IN_S * 60) 1930 #define MS_IN_H (MS_IN_M * 60) 1931 #define MS_IN_D (MS_IN_H * 24) 1932 #define MAXSTR sizeof("..d..h..m..s...ms") 1938 offset += snprintf(str + offset,
MAXSTR - offset,
"%ud",
1943 offset += snprintf(str + offset,
MAXSTR - offset,
"%uh",
1948 offset += snprintf(str + offset,
MAXSTR - offset,
"%um",
1955 offset += snprintf(str + offset,
MAXSTR - offset,
"%u",
1958 if (interval_ms > 0) {
1959 offset += snprintf(str + offset,
MAXSTR - offset,
".%03u",
1962 (void) snprintf(str + offset,
MAXSTR - offset,
"s");
1964 }
else if (interval_ms > 0) {
1965 (void) snprintf(str + offset,
MAXSTR - offset,
"%ums", interval_ms);
1967 }
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)
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)
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)
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)
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.
void pcmk__str_update(char **str, const char *value)
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
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
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)
char * pcmk__trim(char *str)
void crm_time_free_period(crm_time_period_t *period)
Free a dynamically allocated time period object.
#define crm_time_log_date