#include "xroad_common_fwd.h"
#include <common/xroad_time.h>
#include <time.h>
Go to the source code of this file.
◆ xroad_date_to_sql
#define xroad_date_to_sql |
( |
|
v | ) |
|
Value:({ \
char* buf = "NULL"; \
uint32_t len = 4; \
xroad_date_t dt = (v); \
{ \
buf = alloca(s.len + 2); \
buf[0] = '\''; \
memcpy(buf + 1, s.data, s.len); \
buf[s.len + 1] = '\''; \
len = s.len + 2; \
} \
xroad_str_len(buf, len); \
})
bool xroad_date_is_null(xroad_date_t data)
#define xroad_date_to_str(dt)
Definition: xroad_date.h:103
convert xroad_date_t to SQL string representation (NULL, '2020-01-01')
- Parameters
-
- Returns
- SQL string
◆ xroad_date_to_str
#define xroad_date_to_str |
( |
|
dt | ) |
|
Value:({ \
char* buff = alloca(11); \
int32_t s =
xroad_format(buff, 11,
"%04d-%02d-%02d", dt.year, dt.month, dt.day); \
xroad_str_len(buff, s); \
})
convert date to string representation
- Parameters
-
- Returns
- string representation
◆ xroad_date_adjust()
adjust date to N days
- Parameters
-
[in] | dt | - date to adjust |
[in] | day | - days to adjust (can be negative) |
- Returns
- adjusted date
◆ xroad_date_cmp()
compare two dates
- Parameters
-
[in] | dt1 | - first date to compare |
[in] | dt2 | - seconds date to compare |
- Returns
- 0, -1 or 1
◆ xroad_date_create()
xroad_date_t xroad_date_create |
( |
uint16_t |
year, |
|
|
uint8_t |
month, |
|
|
uint8_t |
day |
|
) |
| |
◆ xroad_date_day_of_year()
uint32_t xroad_date_day_of_year |
( |
| ) |
|
- Returns
- current day of year (1-365)
◆ xroad_date_from_int()
convert date represented as int YYYYMMDD (e.g. 20180801) to xroad_date_t struct
- Parameters
-
[in] | date | - integer date representation |
- Returns
- xroad_date_t struct
◆ xroad_date_from_str()
◆ xroad_date_from_tm()
convert tm struct to date
- Parameters
-
[in] | tm | - struct to convert |
- Returns
- xroad_date_t struct
◆ xroad_date_from_ts()
extract date from timestamp in microseconds
- Parameters
-
- Returns
- xroad_date_t struct
◆ xroad_date_is_null()
check if date is null
- Parameters
-
- Returns
- true if date is null, else false
◆ xroad_date_max()
select maximum date among dt1, dt2
- Parameters
-
[in] | dt1 | - first date |
[in] | dt2 | - second date |
- Returns
- maximum date
◆ xroad_date_min()
select minimum date among dt1, dt2
- Parameters
-
[in] | dt1 | - first date |
[in] | dt2 | - second date |
- Returns
- minimum date
◆ xroad_date_to_int()
int32_t xroad_date_to_int |
( |
xroad_date_t |
date, |
|
|
bool |
short_year |
|
) |
| |
convert date to int32 like YYYYMMDD
- Parameters
-
[in] | date | - date to convert #param[in] short_year - will generate YYMMDD, instead of full YYYYMMDD |
- Returns
- int32 date
◆ xroad_date_to_ts()
convert date to timestamp in microseconds
- Parameters
-
[in] | date | - date to convert |
- Returns
- timestamp value