|
int | iso8601_isleap (int year) |
| Is year a leap year? More...
|
|
void | iso8601_to_cal (int *year, int *month, int *day, const struct iso8601_date *date) |
| Convert date to calendar format. More...
|
|
int | iso8601_from_cal (struct iso8601_date *date, int year, int month, int day) |
| Convert date from calendar format. More...
|
|
void | iso8601_to_ord (int *year, int *oday, const struct iso8601_date *date) |
| Convert date to ordinal format. More...
|
|
int | iso8601_from_ord (struct iso8601_date *date, int year, int oday) |
| Convert date from ordinal format. More...
|
|
void | iso8601_to_week (int *year, int *week, int *wday, const struct iso8601_date *date) |
| Convert date to week format. More...
|
|
int | iso8601_from_week (struct iso8601_date *date, int year, int week, int wday) |
| Convert date from week format. More...
|
|
void | iso8601_to_clocktime (int *hour, int *min, int *sec, const struct iso8601_date *date) |
| Convert time to wall clock format. More...
|
|
int | iso8601_from_clocktime (struct iso8601_date *date, int hour, int min, int sec) |
| Convert time from wall clock format. More...
|
|
This set of functions is useful for converting dates and times into formats understood by humans, and vice versa.
◆ iso8601_isleap()
int iso8601_isleap |
( |
int |
year | ) |
|
Is year a leap year?
- Parameters
-
- Return values
-
0 | if not leap year. |
non-0 | if leap year. |
Returns non-0 if year is a leap year.
◆ iso8601_to_cal()
void iso8601_to_cal |
( |
int * |
year, |
|
|
int * |
month, |
|
|
int * |
day, |
|
|
const struct iso8601_date * |
date |
|
) |
| |
Convert date to calendar format.
- Parameters
-
[out] | year | Calendar year. |
[out] | month | Calendar month (1 to 12). |
[out] | day | Calendar day (starting from 1). |
| date | Date to convert. |
◆ iso8601_from_cal()
int iso8601_from_cal |
( |
struct iso8601_date * |
date, |
|
|
int |
year, |
|
|
int |
month, |
|
|
int |
day |
|
) |
| |
Convert date from calendar format.
- Parameters
-
[out] | date | Output date. |
| year | Calendar year. |
| month | Calendar month (1 to 12). |
| day | Calenday day (starting from 1). |
- Return values
-
0 | on success. |
-1 | on error (and see errno). |
Converts the date specified in year, month and day into date.
- Note
- Does not touch the sec or nsec time members of date. This means they will be unchanged after a call to this function. If this will lead to unexpected results, initialise the structure to 0 first.
◆ iso8601_to_ord()
void iso8601_to_ord |
( |
int * |
year, |
|
|
int * |
oday, |
|
|
const struct iso8601_date * |
date |
|
) |
| |
Convert date to ordinal format.
- Parameters
-
[out] | year | Calendar year. |
[out] | oday | Ordinal day (from 1). |
| date | Date to convert. |
◆ iso8601_from_ord()
int iso8601_from_ord |
( |
struct iso8601_date * |
date, |
|
|
int |
year, |
|
|
int |
oday |
|
) |
| |
Convert date from ordinal format.
- Parameters
-
[out] | date | Output date. |
| year | Calendar year. |
| oday | Ordinal day (from 1). |
- Return values
-
0 | on success. |
-1 | on error (and see errno). |
Converts the date specified into year and oday into date.
- Note
- Does not touch the sec or nsec time members of date. This means they will be unchanged after a call to this functoin. If this will lead to unexpected results, initialise the structure to 0 first.
◆ iso8601_to_week()
void iso8601_to_week |
( |
int * |
year, |
|
|
int * |
week, |
|
|
int * |
wday, |
|
|
const struct iso8601_date * |
date |
|
) |
| |
Convert date to week format.
- Parameters
-
[out] | year | Calendar year. |
[out] | week | ISO week number (from 1). |
[out] | wday | ISO week day number (1 = Monday, 7 = Sunday). |
| date | Date to convert. |
◆ iso8601_from_week()
int iso8601_from_week |
( |
struct iso8601_date * |
date, |
|
|
int |
year, |
|
|
int |
week, |
|
|
int |
wday |
|
) |
| |
Convert date from week format.
- Parameters
-
[out] | date | Output date. |
| year | Calendar year. |
| week | ISO week number (from 1). |
| wday | ISO week day number (1 = Monday, 7 = Sunday). |
- Return values
-
0 | on success. |
-1 | on error (and see errno). |
Converts the date specified into year, week and wday into date.
- Note
- Does not touch the sec or nsec time members of date. This means they will be unchanged after a call to this functoin. If this will lead to unexpected results, initialise the structure to 0 first.
◆ iso8601_to_clocktime()
void iso8601_to_clocktime |
( |
int * |
hour, |
|
|
int * |
min, |
|
|
int * |
sec, |
|
|
const struct iso8601_date * |
date |
|
) |
| |
Convert time to wall clock format.
- Parameters
-
[out] | hour | Output hour. |
[out] | min | Output minute. |
[out] | sec | Output second. |
| date | Date/time to convert. |
Converts the time stored in date into wall clock format, storing the result in hour, min and sec.
◆ iso8601_from_clocktime()
int iso8601_from_clocktime |
( |
struct iso8601_date * |
date, |
|
|
int |
hour, |
|
|
int |
min, |
|
|
int |
sec |
|
) |
| |
Convert time from wall clock format.
- Parameters
-
[out] | date | Output time. |
| hour | Hour. |
| min | Minute. |
| sec | Second. |
- Return values
-
0 | on success. |
-1 | on error (and see errno). |
Converts the time as specified by hour, min and sec, storing the result in date.
- Note
- Does not touch the day (date) member of date. This means it will be unchanged after a call to this function. If this will lead to unexpected results, initialise the structure to 0 first.