Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
8c0bc83
Refactor: libcrmcommon: Clarify days_in_month_year()
nrwahl2 Apr 11, 2026
de848bc
Refactor: libcrmcommon: Use g_date_get_days_in_month()
nrwahl2 Apr 12, 2026
233e6a6
Log: libcrmcommon: Drop unhelpful trace logs from crm_time_add_months()
nrwahl2 Apr 12, 2026
e073dec
Refactor: libcrmcommon: Rename a_time and value variables in crm_time.c
nrwahl2 Apr 12, 2026
ad3e868
Refactor: libcrmcommon: Rename ymd variables in crm_time_add_months()
nrwahl2 Apr 12, 2026
a254b90
Refactor: libcrmcommon: Assert before dereferencing in iso8601.c
nrwahl2 Apr 12, 2026
7f5bbf6
Refactor: libcrmcommon: Improve variable names in get_ordinal_days()
nrwahl2 Apr 11, 2026
dc6c795
Refactor: libcrmcommon: Drop redundant check from parse_int()
nrwahl2 Apr 12, 2026
89675ad
Refactor: libcrmcommon: Functionizing parsing a duration element
nrwahl2 Apr 12, 2026
5d4ca39
Refactor: libcrmcommon: Drop some nesting in parse_duration_element()
nrwahl2 Apr 12, 2026
d45db96
Log: libcrmcommon: Improve no-units message in parse_duration_element()
nrwahl2 Apr 12, 2026
d6db32b
Log: libcrmcommon: Simplify overflow logging in parse_duration_element()
nrwahl2 Apr 12, 2026
fd3dace
Low: libcrmcommon: Improve crm_time_get_seconds() for durations
nrwahl2 Apr 12, 2026
a940eb9
Refactor: libcrmcommon: Use g_date_is_leap_year()
nrwahl2 Apr 12, 2026
a76eb5f
Doc: libcrmcommon: Address FIXME comment about GLib version
nrwahl2 Apr 12, 2026
9c32aa3
Refactor: libcrmcommon: New offset_text()
nrwahl2 Apr 12, 2026
d202fb9
Refactor: libcrmcommon: seconds_to_hms() accepts NULL seconds
nrwahl2 Apr 12, 2026
6489138
Refactor: tools: Drop redundant else in crm_rule.c
nrwahl2 Apr 13, 2026
f12cb5f
Refactor: libcrmcommon: Remove some nesting in set_effective_date()
nrwahl2 Apr 16, 2026
938e236
Refactor: libpacemaker: Improve validation in set_effective_date()
nrwahl2 Apr 17, 2026
b5a1e81
Refactor: libcrmcommon: Cast -1 to time_t for comparison
nrwahl2 Apr 26, 2026
cbeba22
Test: cts-cli: Test out-of-range year in interval specification
nrwahl2 Apr 27, 2026
9335433
Feature: libcrmcommon: crm_time_parse_period requires years in [1, 9999]
nrwahl2 Apr 27, 2026
540aafd
Refactor: tools: iso8601 output function doesn't use crm_time_period_t
nrwahl2 Apr 27, 2026
404cf1e
Refactor: tools: Drop crm_time_period_t from iso8601 CLI tool
nrwahl2 Apr 27, 2026
e7c5946
API: libcrmcommon: Deprecate crm_time_parse_period()
nrwahl2 Apr 27, 2026
88f6a0f
API: libcrmcommon: Deprecate crm_time_free_period()
nrwahl2 Apr 27, 2026
4fa3963
API: libcrmcommon: Deprecate crm_time_period_t
nrwahl2 Apr 27, 2026
9f2af21
Feature: tools: crm_rule requires dates to have year between 1 and 9999
nrwahl2 Apr 13, 2026
6d0d175
API: libcrmcommon: Deprecate crm_time_calculate_duration()
nrwahl2 Apr 30, 2026
3db8708
Refactor: libcrmcommon: New pcmk__time_parse_duration()
nrwahl2 Apr 30, 2026
2e523de
API: libcrmcommon: Deprecate crm_time_parse_duration()
nrwahl2 Apr 30, 2026
d2120d7
Refactor: libcrmcommon: Clean up includes in scheduler.h
nrwahl2 May 1, 2026
2691e4b
Refactor: various: Drop crm_time_new_undefined() internally
nrwahl2 May 1, 2026
a07781e
API: libcrmcommon: Deprecate crm_time_new_undefined()
nrwahl2 May 1, 2026
3c2b282
Refactor: libcrmcommon: New pcmk__time_is_initialized()
nrwahl2 May 1, 2026
e5a3ea0
API: libcrmcommon: Deprecate crm_time_is_defined()
nrwahl2 May 1, 2026
0a72341
Refactor: libcrmcommon: New pcmk__time_text()
nrwahl2 May 1, 2026
48ae97a
API: libcrmcommon: Deprecate crm_time_as_string()
nrwahl2 May 1, 2026
7b28de5
Refactor: libcrmcommon: New pcmk__time_fmt_date flag
nrwahl2 May 1, 2026
063772b
API: libcrmcommon: Deprecate crm_time_log_date
nrwahl2 May 1, 2026
a4ff313
Refactor: libcrmcommon: New pcmk__time_fmt_time
nrwahl2 May 1, 2026
aa85aef
API: libcrmcommon: Deprecate crm_time_log_timeofday
nrwahl2 May 1, 2026
5dd68a3
Refactor: libcrmcommon: New pcmk__time_fmt_timezone
nrwahl2 May 1, 2026
d5379fd
API: libcrmcommon: Deprecate crm_time_log_with_timezone
nrwahl2 May 1, 2026
02a69e5
Refactor: libcrmcommon: New pcmk__time_fmt_duration
nrwahl2 May 1, 2026
c48c4df
API: libcrmcommon: Deprecate crm_time_log_duration
nrwahl2 May 1, 2026
0bafb59
Refactor: libcrmcommon: New pcmk__time_fmt_ordinal
nrwahl2 May 1, 2026
7094770
API: libcrmcommon: Deprecate crm_time_ordinal
nrwahl2 May 1, 2026
c1cff63
Refactor: libcrmcommon: New pcmk__time_fmt_weeks
nrwahl2 May 1, 2026
26f882d
API: libcrmcommon: Deprecate crm_time_weeks
nrwahl2 May 1, 2026
6ef57d0
Refactor: libcrmcommon: New pcmk__time_fmt_seconds
nrwahl2 May 1, 2026
f6166d7
API: libcrmcommon: Deprecate crm_time_seconds
nrwahl2 May 1, 2026
6bc12fa
Refactor: libcrmcommon: New pcmk__time_fmt_epoch
nrwahl2 May 1, 2026
b27ba53
API: libcrmcommon: Deprecate crm_time_epoch
nrwahl2 May 1, 2026
1183df5
Refactor: libcrmcommon: New pcmk__time_fmt_usecs
nrwahl2 May 1, 2026
033c4ba
API: libcrmcommon: Deprecate crm_time_usecs
nrwahl2 May 1, 2026
2b97bc3
Refactor: libcrmcommon: New pcmk__time_compare()
nrwahl2 May 1, 2026
a764bec
API: libcrmcommon: Deprecate crm_time_compare()
nrwahl2 May 1, 2026
3cc9ba8
Refactor: libcrmcommon: Ignore crm_time_get_timeofday() return value
nrwahl2 May 1, 2026
19ab05c
Refactor: libcrmcommon: New pcmk__time_get_timeofday()
nrwahl2 May 1, 2026
a207d49
API: libcrmcommon: Deprecate crm_time_get_timeofday()
nrwahl2 May 1, 2026
f740769
Refactor: libcrmcommon: Ignore crm_time_get_gregorian() return value
nrwahl2 May 1, 2026
13e3fff
Refactor: libcrmcommon: New pcmk__time_get_ymd()
nrwahl2 May 1, 2026
65279c9
API: libcrmcommon: Deprecate crm_time_get_gregorian()
nrwahl2 May 1, 2026
df5742c
Refactor: libcrmcommon: Drop crm_time_get_ordinal() internally
nrwahl2 May 1, 2026
ce187d8
API: libcrmcommon: Deprecate crm_time_get_ordinal()
nrwahl2 May 1, 2026
217d443
Refactor: libcrmcommon: New pcmk__time_get_seconds()
nrwahl2 May 1, 2026
5c9d48b
API: libcrmcommon: Deprecate crm_time_get_seconds()
nrwahl2 May 1, 2026
776bdbf
Refactor: libcrmcommon: Make pcmk__time_get_ywd() library-private
nrwahl2 May 1, 2026
01a8ef4
Refactor: libcrmcommon: New pcmk__time_to_unix()
nrwahl2 May 1, 2026
d7b3413
API: libcrmcommon: Deprecate crm_time_get_seconds_since_epoch()
nrwahl2 May 1, 2026
aef4bea
Refactor: various: Drop crm_time_free() internally
nrwahl2 May 1, 2026
1b5ea9e
API: libcrmcommon: Deprecate crm_time_free()
nrwahl2 May 1, 2026
a909bd9
Refactor: libcrmcommon: New pcmk__time_copy()
nrwahl2 May 1, 2026
42676ad
API: libcrmcommon: Deprecate pcmk_copy_time()
nrwahl2 May 1, 2026
84c17b0
Refactor: libcrmcommon: New pcmk__time_add()
nrwahl2 May 1, 2026
1211b75
API: libcrmcommon: Deprecate crm_time_add()
nrwahl2 May 1, 2026
e2b29f5
Refactor: libcrmcommon: New pcmk__time_subtract()
nrwahl2 May 1, 2026
f40d14c
API: libcrmcommon: Deprecate crm_time_subtract()
nrwahl2 May 1, 2026
5a035c2
Refactor: libcrmcommon: New pcmk__time_add_seconds()
nrwahl2 May 1, 2026
f95140c
API: libcrmcommon: Deprecate crm_time_add_seconds()
nrwahl2 May 1, 2026
6346c49
API: libcrmcommon: Deprecate crm_time_add_minutes()
nrwahl2 May 1, 2026
1a8503c
API: libcrmcommon: Deprecate crm_time_add_hours()
nrwahl2 May 1, 2026
14f0516
Refactor: libcrmcommon: New pcmk__time_add_days()
nrwahl2 May 1, 2026
b043bbf
API: libcrmcommon: Deprecate crm_time_add_days()
nrwahl2 May 1, 2026
00b14d5
API: libcrmcommon: Deprecate crm_time_add_weeks()
nrwahl2 May 1, 2026
ed56b7d
API: libcrmcommon: Deprecate crm_time_add_months()
nrwahl2 May 1, 2026
d7aca01
Refactor: libcrmcommon: New pcmk__time_add_years()
nrwahl2 May 1, 2026
c7ef9b7
API: libcrmcommon: Deprecate crm_time_add_years()
nrwahl2 May 1, 2026
13cd9e7
Refactor: libcrmcommon: Drop unused includes from iso8601.h
nrwahl2 May 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions cts/cli/regression.dates.exp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=#=#=#= Begin test: Invalid period - [] =#=#=#=
crm_time_parse_period error: No ISO 8601 time period given
parse_period error: No ISO 8601 time period given
iso8601: Invalid interval specified:
=#=#=#= End test: Invalid period - [] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - []
=#=#=#= Begin test: Invalid period - [2019-01-01 00:00:00Z] =#=#=#=
crm_time_parse_period error: '2019-01-01 00:00:00Z' is not a valid ISO 8601 time period because it has no duration or ending time
parse_period error: '2019-01-01 00:00:00Z' is not a valid ISO 8601 time period because it has no duration or ending time
iso8601: Invalid interval specified: 2019-01-01 00:00:00Z
=#=#=#= End test: Invalid period - [2019-01-01 00:00:00Z] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [2019-01-01 00:00:00Z]
Expand All @@ -14,7 +14,7 @@ iso8601: Invalid interval specified: 2019-01-01 00:00:00Z/
=#=#=#= End test: Invalid period - [2019-01-01 00:00:00Z/] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [2019-01-01 00:00:00Z/]
=#=#=#= Begin test: Invalid period - [PT2S/P1M] =#=#=#=
crm_time_parse_period error: 'PT2S/P1M' is not a valid ISO 8601 time period because it has two durations
parse_period error: 'PT2S/P1M' is not a valid ISO 8601 time period because it has two durations
iso8601: Invalid interval specified: PT2S/P1M
=#=#=#= End test: Invalid period - [PT2S/P1M] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [PT2S/P1M]
Expand Down Expand Up @@ -64,20 +64,35 @@ iso8601: Invalid interval specified: P1Y/2019-02-29 00:00:00Z
=#=#=#= End test: Invalid period - [P1Y/2019-02-29 00:00:00Z] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [P1Y/2019-02-29 00:00:00Z]
=#=#=#= Begin test: Invalid period - [2019-01-01 00:00:00Z/P] =#=#=#=
crm_time_parse_duration error: 'P' is not a valid ISO 8601 time duration because nothing follows 'P'
pcmk__time_parse_duration error: 'P' is not a valid ISO 8601 time duration because nothing follows 'P'
iso8601: Invalid interval specified: 2019-01-01 00:00:00Z/P
=#=#=#= End test: Invalid period - [2019-01-01 00:00:00Z/P] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [2019-01-01 00:00:00Z/P]
=#=#=#= Begin test: Invalid period - [P1Z/2019-02-20 00:00:00Z] =#=#=#=
crm_time_parse_duration error: 'P1Z/2019-02-20 00:00:00Z' is not a valid ISO 8601 time duration because 'Z' is not a valid time unit
parse_duration_element error: 'P1Z/2019-02-20 00:00:00Z' is not a valid ISO 8601 duration because 'Z' is not a valid time unit
iso8601: Invalid interval specified: P1Z/2019-02-20 00:00:00Z
=#=#=#= End test: Invalid period - [P1Z/2019-02-20 00:00:00Z] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [P1Z/2019-02-20 00:00:00Z]
=#=#=#= Begin test: Invalid period - [P1YM/2019-02-20 00:00:00Z] =#=#=#=
crm_time_parse_duration error: 'P1YM/2019-02-20 00:00:00Z' is not a valid ISO 8601 time duration because no valid integer at 'M/2019-02-20 00:00:00Z'
parse_duration_element error: 'P1YM/2019-02-20 00:00:00Z' is not a valid ISO 8601 duration because no valid integer at 'M/2019-02-20 00:00:00Z'
iso8601: Invalid interval specified: P1YM/2019-02-20 00:00:00Z
=#=#=#= End test: Invalid period - [P1YM/2019-02-20 00:00:00Z] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [P1YM/2019-02-20 00:00:00Z]
=#=#=#= Begin test: Invalid period - [0000-10-01T00:00:00Z/P1M] =#=#=#=
parse_date error: '0000-10-01T00:00:00Z/P1M' is not a valid ISO 8601 date/time specification because '0' is not a valid year
iso8601: Invalid interval specified: 0000-10-01T00:00:00Z/P1M
=#=#=#= End test: Invalid period - [0000-10-01T00:00:00Z/P1M] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [0000-10-01T00:00:00Z/P1M]
=#=#=#= Begin test: Invalid period - [-0001-10-01T00:00:00Z/P1M] =#=#=#=
parse_date error: '-0001-10-01T00:00:00Z/P1M' is not a valid ISO 8601 date/time specification because '4294967295' is not a valid year
iso8601: Invalid interval specified: -0001-10-01T00:00:00Z/P1M
=#=#=#= End test: Invalid period - [-0001-10-01T00:00:00Z/P1M] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [-0001-10-01T00:00:00Z/P1M]
=#=#=#= Begin test: Invalid period - [10000-10-01T00:00:00Z/P1M] =#=#=#=
parse_period error: 'P1M' is not a valid ISO 8601 time period because the start is invalid (must be between 0001-01-01T00:00:00 and 9999-12-31T23:59:59)
iso8601: Invalid interval specified: 10000-10-01T00:00:00Z/P1M
=#=#=#= End test: Invalid period - [10000-10-01T00:00:00Z/P1M] - Invalid parameter (2) =#=#=#=
* Passed: iso8601 - Invalid period - [10000-10-01T00:00:00Z/P1M]
=#=#=#= Begin test: '2005-040/2005-043' period =#=#=#=
Period: 2005-02-09 00:00:00Z to 2005-02-12 00:00:00Z
=#=#=#= End test: '2005-040/2005-043' period - OK (0) =#=#=#=
Expand Down
9 changes: 6 additions & 3 deletions cts/cts-cli.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# We know this is a very long file.
# pylint: disable=too-many-lines

__copyright__ = "Copyright 2024-2025 the Pacemaker project contributors"
__copyright__ = "Copyright 2024-2026 the Pacemaker project contributors"
__license__ = "GNU General Public License version 2 or later (GPLv2+) WITHOUT ANY WARRANTY"

import argparse
Expand Down Expand Up @@ -251,8 +251,6 @@ def sanitize_output(s):
(r'(<cib.*) cib-last-written="[^"]*"', r'\1'),
(r'crm_feature_set="[^"]*" ', r''),
(r'@crm_feature_set=[0-9.]+, ', r''),
(r'\(crm_time_parse_duration@.*\.c:[0-9]+\)', r'crm_time_parse_duration'),
(r'\(crm_time_parse_period@.*\.c:[0-9]+\)', r'crm_time_parse_period'),
(r'\(parse_hms@.*\.c:[0-9]+\)', r'parse_hms'),
(re.escape(cts_cli_data), r'CTS_CLI_DATA'),
(r' default="[^"]*"', r' default=""'),
Expand All @@ -261,6 +259,8 @@ def sanitize_output(s):
(r'last_update time=".*"', r'last_update time=""'),
(r' last-rc-change=[\'"][-+A-Za-z0-9: ]*[\'"],?', r''),
(r'\(parse_date@.*\.c:[0-9]+\)', r'parse_date'),
(r'\(parse_duration_element@.*\.c:[0-9]+\)', r'parse_duration_element'),
(r'\(parse_period@.*\.c:[0-9]+\)', r'parse_period'),
(r'\((pcmk__.*)@.*\.c:[0-9]+\)', r'\1'),
(r'.*Relax-NG validity error : ', r''),
(r'request=".*cibadmin', r'request="cibadmin'),
Expand Down Expand Up @@ -1115,6 +1115,9 @@ class DatesRegressionTest(RegressionTest):
"2019-01-01 00:00:00Z/P", # Duration with no values
"P1Z/2019-02-20 00:00:00Z", # Invalid duration unit
"P1YM/2019-02-20 00:00:00Z", # No number for duration unit
"0000-10-01T00:00:00Z/P1M", # Zero year
"-0001-10-01T00:00:00Z/P1M", # Negative year
"10000-10-01T00:00:00Z/P1M", # Year greater than 9999
]

# Ensure invalid period specifications are rejected
Expand Down
2 changes: 1 addition & 1 deletion daemons/controld/controld_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ config_query_callback(xmlNode * msg, int call_id, int rc, xmlNode * output, void

g_hash_table_destroy(config_hash);
bail:
crm_time_free(now);
free(now);
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion daemons/controld/controld_remote_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ remote_config_check(xmlNode *msg, int call_id, int rc, xmlNode *output,
lrmd__validate_remote_settings(lrmd, config_hash);

g_hash_table_destroy(config_hash);
crm_time_free(now);
free(now);
}

/*!
Expand Down
65 changes: 0 additions & 65 deletions include/crm/common/iso8601.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#ifndef PCMK__CRM_COMMON_ISO8601__H
#define PCMK__CRM_COMMON_ISO8601__H

#include <ctype.h>
#include <stdbool.h> // bool
#include <stdint.h> // uint32_t
#include <time.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -38,16 +33,6 @@ extern "C" {
*/
typedef struct crm_time_s crm_time_t;

/*!
* \deprecated Use \c crm_time_period_t instead of
* <tt>struct crm_time_period_s</tt>.
*/
typedef struct crm_time_period_s {
crm_time_t *start;
crm_time_t *end;
crm_time_t *diff;
} crm_time_period_t;

/* Creates a new date/time object conforming to ISO 8601, for example:
* Ordinal: 2010-01 12:00:00 +10:00
* Gregorian: 2010-01-01 12:00:00 +10:00
Expand All @@ -62,56 +47,6 @@ typedef struct crm_time_period_s {
* A timezone of 'Z' denotes UTC time
*/
crm_time_t *crm_time_new(const char *string);
crm_time_t *crm_time_new_undefined(void);
void crm_time_free(crm_time_t * dt);

bool crm_time_is_defined(const crm_time_t *t);
char *crm_time_as_string(const crm_time_t *dt, int flags);

#define crm_time_log_date 0x001
#define crm_time_log_timeofday 0x002
#define crm_time_log_with_timezone 0x004
#define crm_time_log_duration 0x008

#define crm_time_ordinal 0x010
#define crm_time_weeks 0x020
#define crm_time_seconds 0x100
#define crm_time_epoch 0x200
#define crm_time_usecs 0x400

crm_time_t *crm_time_parse_duration(const char *duration_str);
crm_time_t *crm_time_calculate_duration(const crm_time_t *dt,
const crm_time_t *value);
crm_time_period_t *crm_time_parse_period(const char *period_str);
void crm_time_free_period(crm_time_period_t *period);

int crm_time_compare(const crm_time_t *a, const crm_time_t *b);

int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m,
uint32_t *s);
int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m,
uint32_t *d);
int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d);

/* Time in seconds since 0000-01-01 00:00:00Z */
long long crm_time_get_seconds(const crm_time_t *dt);

/* Time in seconds since 1970-01-01 00:00:00Z */
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt);

/* Returns a new time object */
crm_time_t *pcmk_copy_time(const crm_time_t *source);
crm_time_t *crm_time_add(const crm_time_t *dt, const crm_time_t *value);
crm_time_t *crm_time_subtract(const crm_time_t *dt, const crm_time_t *value);

/* All crm_time_add_... functions support negative values */
void crm_time_add_seconds(crm_time_t * dt, int value);
void crm_time_add_minutes(crm_time_t * dt, int value);
void crm_time_add_hours(crm_time_t * dt, int value);
void crm_time_add_days(crm_time_t * dt, int value);
void crm_time_add_weeks(crm_time_t * dt, int value);
void crm_time_add_months(crm_time_t * dt, int value);
void crm_time_add_years(crm_time_t * dt, int value);

#ifdef __cplusplus
}
Expand Down
111 changes: 110 additions & 1 deletion include/crm/common/iso8601_compat.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2025 the Pacemaker project contributors
* Copyright 2004-2026 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
Expand Down Expand Up @@ -29,6 +29,40 @@ extern "C" {
* release.
*/

//! \deprecated Do not use
#define crm_time_log_date 0x001

//! \deprecated Do not use
#define crm_time_log_timeofday 0x002

//! \deprecated Do not use
#define crm_time_log_with_timezone 0x004

//! \deprecated Do not use
#define crm_time_log_duration 0x008

//! \deprecated Do not use
#define crm_time_ordinal 0x010

//! \deprecated Do not use
#define crm_time_weeks 0x020

//! \deprecated Do not use
#define crm_time_seconds 0x100

//! \deprecated Do not use
#define crm_time_epoch 0x200

//! \deprecated Do not use
#define crm_time_usecs 0x400

//! \deprecated Do not use
typedef struct crm_time_period_s {
crm_time_t *start;
crm_time_t *end;
crm_time_t *diff;
} crm_time_period_t;

//! \deprecated Do not use
bool crm_time_leapyear(int year);

Expand Down Expand Up @@ -66,6 +100,81 @@ 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);

//! \deprecated Do not use
void crm_time_free_period(crm_time_period_t *period);

//! \deprecated Do not use
crm_time_period_t *crm_time_parse_period(const char *period_str);

//! \deprecated Do not use
crm_time_t *crm_time_calculate_duration(const crm_time_t *dt,
const crm_time_t *value);

//! \deprecated Do not use
crm_time_t *crm_time_parse_duration(const char *duration_str);

//! \deprecated Do not use
crm_time_t *crm_time_new_undefined(void);

//! \deprecated Do not use
bool crm_time_is_defined(const crm_time_t *t);

//! \deprecated Do not use
char *crm_time_as_string(const crm_time_t *dt, int flags);

//! \deprecated Do not use
int crm_time_compare(const crm_time_t *a, const crm_time_t *b);

//! \deprecated Do not use
int crm_time_get_timeofday(const crm_time_t *dt, uint32_t *h, uint32_t *m,
uint32_t *s);

//! \deprecated Do not use
int crm_time_get_gregorian(const crm_time_t *dt, uint32_t *y, uint32_t *m,
uint32_t *d);

//! \deprecated Do not use
int crm_time_get_ordinal(const crm_time_t *dt, uint32_t *y, uint32_t *d);

//! \deprecated Do not use
long long crm_time_get_seconds(const crm_time_t *dt);

//! \deprecated Do not use
long long crm_time_get_seconds_since_epoch(const crm_time_t *dt);

//! \deprecated Use \c free() instead
void crm_time_free(crm_time_t *dt);

//! \deprecated Do not use
crm_time_t *pcmk_copy_time(const crm_time_t *source);

//! \deprecated Do not use
crm_time_t *crm_time_add(const crm_time_t *dt, const crm_time_t *value);

//! \deprecated Do not use
crm_time_t *crm_time_subtract(const crm_time_t *dt, const crm_time_t *value);

//! \deprecated Do not use
void crm_time_add_seconds(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_minutes(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_hours(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_days(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_weeks(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_months(crm_time_t *dt, int value);

//! \deprecated Do not use
void crm_time_add_years(crm_time_t *dt, int value);

#ifdef __cplusplus
}
#endif
Expand Down
44 changes: 42 additions & 2 deletions include/crm/common/iso8601_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,51 @@
extern "C" {
#endif

void pcmk__time_get_ywd(const crm_time_t *dt, uint32_t *y, uint32_t *w,
uint32_t *d);
/* @COMPAT These must be kept in line with the deprecated crm_time_* flags until
* those are removed
*/
enum pcmk__time_fmt_flags {
pcmk__time_fmt_date = (UINT32_C(1) << 0),
pcmk__time_fmt_time = (UINT32_C(1) << 1),
pcmk__time_fmt_timezone = (UINT32_C(1) << 2),

// @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated)
pcmk__time_fmt_duration = (UINT32_C(1) << 3),

// @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated)
pcmk__time_fmt_ordinal = (UINT32_C(1) << 4),

// @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated)
pcmk__time_fmt_weeks = (UINT32_C(1) << 5),

// @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated)
pcmk__time_fmt_seconds = (UINT32_C(1) << 8),

// @COMPAT Nothing sets this internally except tools/iso8601.c (deprecated)
pcmk__time_fmt_epoch = (UINT32_C(1) << 9),

pcmk__time_fmt_usecs = (UINT32_C(1) << 10),
};

bool pcmk__time_valid_year(int year);

crm_time_t *pcmk__time_copy(const crm_time_t *source);

bool pcmk__time_is_initialized(const crm_time_t *dt);
long long pcmk__time_get_seconds(const crm_time_t *dt);
long long pcmk__time_to_unix(const crm_time_t *dt);
char *pcmk__time_text(const crm_time_t *dt, int flags);
char *pcmk__time_format_hr(const char *format, const crm_time_t *dt, int usec);
char *pcmk__epoch2str(const time_t *source, uint32_t flags);
char *pcmk__timespec2str(const struct timespec *ts, uint32_t flags);
const char *pcmk__readable_interval(guint interval_ms);

crm_time_t *pcmk__time_parse_duration(const char *period_s);
crm_time_t *pcmk__copy_timet(time_t source_sec);
crm_time_t *pcmk__time_add(const crm_time_t *dt, const crm_time_t *value);
crm_time_t *pcmk__time_subtract(const crm_time_t *dt, const crm_time_t *value);

int pcmk__time_compare(const crm_time_t *a, const crm_time_t *b);

void pcmk__time_log_as(const char *file, const char *function, int line,
uint8_t level, const char *prefix, const crm_time_t *dt,
Expand Down Expand Up @@ -63,6 +101,8 @@ struct crm_time_s {
bool duration;
};

bool valid_time(const crm_time_t *dt);

#ifdef __cplusplus
}
#endif
Expand Down
Loading