pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
Data Structures | Macros | Typedefs | Functions
iso8601.h File Reference

ISO_8601 Date handling. More...

#include <time.h>
#include <ctype.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for iso8601.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crm_time_period_s
 

Macros

#define crm_time_log(level, prefix, dt, flags)   crm_time_log_alias(level, __FILE__, __func__, __LINE__, prefix, dt, 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
 

Typedefs

typedef struct crm_time_s crm_time_t
 
typedef struct crm_time_period_s crm_time_period_t
 

Functions

crm_time_tcrm_time_new (const char *string)
 
crm_time_tcrm_time_new_undefined (void)
 Allocate memory for an uninitialized time object. More...
 
void crm_time_free (crm_time_t *dt)
 
bool crm_time_is_defined (const crm_time_t *t)
 Check whether a time object has been initialized yet. More...
 
char * crm_time_as_string (const crm_time_t *dt, int flags)
 Get a string representation of a crm_time_t object. More...
 
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)
 
crm_time_tcrm_time_parse_duration (const char *duration_str)
 Parse a time duration from an ISO 8601 duration specification. More...
 
crm_time_tcrm_time_calculate_duration (const crm_time_t *dt, const crm_time_t *value)
 
crm_time_period_tcrm_time_parse_period (const char *period_str)
 Parse a time period from an ISO 8601 interval specification. More...
 
void crm_time_free_period (crm_time_period_t *period)
 Free a dynamically allocated time period object. More...
 
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_timezone (const crm_time_t *dt, uint32_t *h, uint32_t *m)
 
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)
 
int crm_time_get_isoweek (const crm_time_t *dt, uint32_t *y, uint32_t *w, uint32_t *d)
 
long long crm_time_get_seconds (const crm_time_t *dt)
 
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)
 
void crm_time_set_timet (crm_time_t *target, const time_t *source)
 
crm_time_tpcmk_copy_time (const crm_time_t *source)
 
crm_time_tcrm_time_add (const crm_time_t *dt, const crm_time_t *value)
 
crm_time_tcrm_time_subtract (const crm_time_t *dt, const crm_time_t *value)
 
void crm_time_add_seconds (crm_time_t *dt, int value)
 Add a given number of seconds to a date/time or duration. More...
 
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)
 
int crm_time_january1_weekday (int year)
 
int crm_time_weeks_in_year (int year)
 
int crm_time_days_in_month (int month, int year)
 Return number of days in given month of given year. More...
 
bool crm_time_leapyear (int year)
 
bool crm_time_check (const crm_time_t *dt)
 Check whether a time object represents a sensible date/time. More...
 

Detailed Description

ISO_8601 Date handling.

Definition in file iso8601.h.

Macro Definition Documentation

◆ crm_time_epoch

#define crm_time_epoch   0x200

Definition at line 75 of file iso8601.h.

◆ crm_time_log

#define crm_time_log (   level,
  prefix,
  dt,
  flags 
)    crm_time_log_alias(level, __FILE__, __func__, __LINE__, prefix, dt, flags)

Definition at line 60 of file iso8601.h.

◆ crm_time_log_date

#define crm_time_log_date   0x001

Definition at line 67 of file iso8601.h.

◆ crm_time_log_duration

#define crm_time_log_duration   0x008

Definition at line 70 of file iso8601.h.

◆ crm_time_log_timeofday

#define crm_time_log_timeofday   0x002

Definition at line 68 of file iso8601.h.

◆ crm_time_log_with_timezone

#define crm_time_log_with_timezone   0x004

Definition at line 69 of file iso8601.h.

◆ crm_time_ordinal

#define crm_time_ordinal   0x010

Definition at line 72 of file iso8601.h.

◆ crm_time_seconds

#define crm_time_seconds   0x100

Definition at line 74 of file iso8601.h.

◆ crm_time_usecs

#define crm_time_usecs   0x400

Definition at line 76 of file iso8601.h.

◆ crm_time_weeks

#define crm_time_weeks   0x020

Definition at line 73 of file iso8601.h.

Typedef Documentation

◆ crm_time_period_t

◆ crm_time_t

typedef struct crm_time_s crm_time_t

Definition at line 32 of file iso8601.h.

Function Documentation

◆ crm_time_add()

crm_time_t* crm_time_add ( const crm_time_t dt,
const crm_time_t value 
)

Definition at line 1400 of file iso8601.c.

◆ crm_time_add_days()

void crm_time_add_days ( crm_time_t dt,
int  value 
)

Definition at line 1568 of file iso8601.c.

◆ crm_time_add_hours()

void crm_time_add_hours ( crm_time_t dt,
int  value 
)

Definition at line 1642 of file iso8601.c.

◆ crm_time_add_minutes()

void crm_time_add_minutes ( crm_time_t dt,
int  value 
)

Definition at line 1636 of file iso8601.c.

◆ crm_time_add_months()

void crm_time_add_months ( crm_time_t dt,
int  value 
)

Definition at line 1593 of file iso8601.c.

◆ crm_time_add_seconds()

void crm_time_add_seconds ( crm_time_t a_time,
int  extra 
)

Add a given number of seconds to a date/time or duration.

Parameters
[in,out]a_timeDate/time or duration to add seconds to
[in]extraNumber of seconds to add

Definition at line 1548 of file iso8601.c.

◆ crm_time_add_weeks()

void crm_time_add_weeks ( crm_time_t dt,
int  value 
)

Definition at line 1648 of file iso8601.c.

◆ crm_time_add_years()

void crm_time_add_years ( crm_time_t dt,
int  value 
)

Definition at line 1654 of file iso8601.c.

◆ crm_time_as_string()

char* crm_time_as_string ( const crm_time_t dt,
int  flags 
)

Get a string representation of a crm_time_t object.

Parameters
[in]dtTime to convert to string
[in]flagsGroup of crm_time_* string format options
Note
The caller is responsible for freeing the return value using free().

Definition at line 694 of file iso8601.c.

◆ crm_time_calculate_duration()

crm_time_t* crm_time_calculate_duration ( const crm_time_t dt,
const crm_time_t value 
)

Definition at line 1428 of file iso8601.c.

◆ crm_time_check()

bool crm_time_check ( const crm_time_t dt)

Check whether a time object represents a sensible date/time.

Parameters
[in]dtDate/time object to check
Returns
true if years, days, and seconds are sensible, false otherwise

Definition at line 1497 of file iso8601.c.

◆ crm_time_compare()

int crm_time_compare ( const crm_time_t a,
const crm_time_t b 
)

Definition at line 1518 of file iso8601.c.

◆ crm_time_days_in_month()

int crm_time_days_in_month ( int  month,
int  year 
)

Return number of days in given month of given year.

Parameters
[in]Ordinalmonth (1-12)
[in]Gregorianyear
Returns
Number of days in given month (0 if given month is invalid)

Definition at line 224 of file iso8601.c.

◆ crm_time_free()

void crm_time_free ( crm_time_t dt)

Definition at line 150 of file iso8601.c.

◆ crm_time_free_period()

void crm_time_free_period ( crm_time_period_t period)

Free a dynamically allocated time period object.

Parameters
[in,out]periodTime period to free

Definition at line 1294 of file iso8601.c.

◆ crm_time_get_gregorian()

int crm_time_get_gregorian ( const crm_time_t dt,
uint32_t *  y,
uint32_t *  m,
uint32_t *  d 
)

Definition at line 365 of file iso8601.c.

◆ crm_time_get_isoweek()

int crm_time_get_isoweek ( const crm_time_t dt,
uint32_t *  y,
uint32_t *  w,
uint32_t *  d 
)

Definition at line 406 of file iso8601.c.

◆ crm_time_get_ordinal()

int crm_time_get_ordinal ( const crm_time_t dt,
uint32_t *  y,
uint32_t *  d 
)

Definition at line 398 of file iso8601.c.

◆ crm_time_get_seconds()

long long crm_time_get_seconds ( const crm_time_t dt)

Definition at line 316 of file iso8601.c.

◆ crm_time_get_seconds_since_epoch()

long long crm_time_get_seconds_since_epoch ( const crm_time_t dt)

Definition at line 359 of file iso8601.c.

◆ crm_time_get_timeofday()

int crm_time_get_timeofday ( const crm_time_t dt,
uint32_t *  h,
uint32_t *  m,
uint32_t *  s 
)

Definition at line 299 of file iso8601.c.

◆ crm_time_get_timezone()

int crm_time_get_timezone ( const crm_time_t dt,
uint32_t *  h,
uint32_t *  m 
)

Definition at line 307 of file iso8601.c.

◆ crm_time_is_defined()

bool crm_time_is_defined ( const crm_time_t t)

Check whether a time object has been initialized yet.

Parameters
[in]tTime object to check
Returns
TRUE if time object has been initialized, FALSE otherwise

Definition at line 142 of file iso8601.c.

◆ crm_time_january1_weekday()

int crm_time_january1_weekday ( int  year)

Definition at line 178 of file iso8601.c.

◆ crm_time_leapyear()

bool crm_time_leapyear ( int  year)

Definition at line 236 of file iso8601.c.

◆ crm_time_log_alias()

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 
)

Definition at line 261 of file iso8601.c.

◆ crm_time_new()

crm_time_t* crm_time_new ( const char *  string)

Definition at line 109 of file iso8601.c.

◆ crm_time_new_undefined()

crm_time_t* crm_time_new_undefined ( void  )

Allocate memory for an uninitialized time object.

Returns
Newly allocated time object
Note
The caller is responsible for freeing the return value using crm_time_free().

Definition at line 126 of file iso8601.c.

◆ crm_time_parse_duration()

crm_time_t* crm_time_parse_duration ( const char *  period_s)

Parse a time duration from an ISO 8601 duration specification.

Parameters
[in]period_sISO 8601 duration specification (optionally followed by whitespace, after which the rest of the string will be ignored)
Returns
New time object on success, NULL (and set errno) otherwise
Note
It is the caller's responsibility to return the result using crm_time_free().

Definition at line 1095 of file iso8601.c.

◆ crm_time_parse_period()

crm_time_period_t* crm_time_parse_period ( const char *  period_str)

Parse a time period from an ISO 8601 interval specification.

Parameters
[in]period_strISO 8601 interval specification (start/end, start/duration, or duration/end)
Returns
New time period object on success, NULL (and set errno) otherwise
Note
The caller is responsible for freeing the result using crm_time_free_period().

Definition at line 1203 of file iso8601.c.

◆ crm_time_set()

void crm_time_set ( crm_time_t target,
const crm_time_t source 
)

Definition at line 1305 of file iso8601.c.

◆ crm_time_set_timet()

void crm_time_set_timet ( crm_time_t target,
const time_t *  source 
)

Definition at line 1368 of file iso8601.c.

◆ crm_time_subtract()

crm_time_t* crm_time_subtract ( const crm_time_t dt,
const crm_time_t value 
)

Definition at line 1462 of file iso8601.c.

◆ crm_time_weeks_in_year()

int crm_time_weeks_in_year ( int  year)

Definition at line 191 of file iso8601.c.

◆ pcmk_copy_time()

crm_time_t* pcmk_copy_time ( const crm_time_t source)

Definition at line 1374 of file iso8601.c.