Deprecate crm_time_calculate_duration() through crm_time_get_seconds()#4130
Deprecate crm_time_calculate_duration() through crm_time_get_seconds()#4130nrwahl2 wants to merge 40 commits into
Conversation
Pacemaker should not be used for general-purpose date/time manipulation. There's no need to calculate a duration (as the difference between two crm_time_t objects) for the purpose of administering Pacemaker. Where Pacemaker uses durations, it parses them directly from strings. A crm_time_t object can be displayed as a string if desired, and then a user can compare two strings through whatever method they desire. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_parse_duration(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Pacemaker parses durations from strings in a few places. However, there is no need for external code to do this for the purpose of administering Pacemaker. Pacemaker should not be used for general-purpose date/time manipulation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Add a couple of missing includes elsewhere, since they break otherwise. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Use crm_time_new() to create a new crm_time_t object from a string (or NULL to use the current time). There is no need for external callers to create an uninitialized object and then set the fields (such as years) later. Pacemaker should not be used for general-purpose date/time manipulation. pcmk_evaluate_rule() can take an uninitialized (undefined) crm_time_t object as the next_change argument and update it as appropriate. However, that argument is for use by the scheduler, not for external callers. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_is_defined(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers should always be using crm_time_new() to create a
crm_time_t object. Such objects will be initialized ("defined").
Pacemaker does not return crm_time_t objects via public API functions,
except as an output argument of pcmk_evaluate_rule(). However, that
argument is for use by the scheduler, not for external callers.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_as_string(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Pacemaker should not be used for general-purpose date/time manipulation. It also does not return crm_time_t objects (except in the case of pcmk_evaluate_rule(), as discussed in previous commit messages). So external callers have no need to convert a crm_time_t to a string representation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_log_date. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_log_timeofday. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_log_with_timezone. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_log_duration. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_ordinal. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_weeks. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_seconds. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_epoch. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_usecs. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_compare(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
It's always TRUE. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_get_timeofday(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to inspect a crm_time_t object. Pacemaker should not be used for general-purpose date/time manipulation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
It always returns TRUE. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_get_gregorian(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to inspect a crm_time_t object. Pacemaker should not be used for general-purpose date/time manipulation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to inspect a crm_time_t object. Pacemaker should not be used for general-purpose date/time manipulation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
To replace crm_time_get_seconds(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
External callers have no need to inspect a crm_time_t object. Pacemaker should not be used for general-purpose date/time manipulation. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
3bb2fcd to
9629516
Compare
| @@ -1,110 +0,0 @@ | |||
| /* | |||
There was a problem hiding this comment.
This should be added to .gitignore, too.
| || (dt->days != 0) | ||
| || (dt->seconds != 0) | ||
| || (dt->offset != 0) | ||
| || (dt->duration)); |
There was a problem hiding this comment.
Parens around dt->duration seems excessive.
| * those are removed | ||
| */ | ||
| enum pcmk__time_fmt_flags { | ||
| pcmk__time_fmt_date = (UINT32_C(1) << 0), |
There was a problem hiding this comment.
It'd be nice to have a comment about what each of these flags does.
| */ | ||
| enum pcmk__time_fmt_flags { | ||
| pcmk__time_fmt_date = (UINT32_C(1) << 0), | ||
| }; |
There was a problem hiding this comment.
Also, I didn't see that a future commit added a pcmk__set_time_fmt_flags/pcmk__clear_time_fmt_flags, but that might be something to consider. We use that approach all over the place.
|
|
||
| int | ||
| crm_time_compare(const crm_time_t *a, const crm_time_t *b) | ||
| pcmk__time_compare(const crm_time_t *a, const crm_time_t *b) |
There was a problem hiding this comment.
Add a doxygen block for this function.
|
|
||
| void | ||
| pcmk__time_get_timeofday(const crm_time_t *dt, uint32_t *hour, | ||
| uint32_t *minute, uint32_t *second) |
There was a problem hiding this comment.
Add a doxygen block for the new function.
| crm_time_get_timeofday(now, &(ranges[3].value), &(ranges[4].value), | ||
| &(ranges[5].value)); | ||
| pcmk__time_get_timeofday(now, &(ranges[3].value), &(ranges[4].value), | ||
| &(ranges[5].value)); |
There was a problem hiding this comment.
Not for this PR, but the parens aren't necessary on these parameters. I know we have this same style all over the place.
| uint32_t *d) | ||
| void | ||
| pcmk__time_get_ymd(const crm_time_t *dt, uint32_t *year, uint32_t *month, | ||
| uint32_t *day) |
| return pcmk__time_get_seconds(dt); | ||
| } | ||
|
|
||
| #define EPOCH_SECONDS 62135596800ULL // Calculated using pcmk__time_get_seconds |
There was a problem hiding this comment.
What does this magic constant represent?
This is the next batch from #4097.