|
int | iso8601_lt (const struct iso8601_date *d1, const struct iso8601_date *d2) |
| Comparison (less than). More...
|
|
int | iso8601_lte (const struct iso8601_date *d1, const struct iso8601_date *d2) |
| Comparison (less than or equal to). More...
|
|
int | iso8601_eq (const struct iso8601_date *d1, const struct iso8601_date *d2) |
| Comparison (equality). More...
|
|
int | iso8601_cmp (const struct iso8601_date *d1, const struct iso8601_date *d2) |
| Comparison (for qsort et al.). More...
|
|
void | iso8601_add_elapsed (struct iso8601_date *date, const struct iso8601_elapsed *per) |
| Add a period to a date. More...
|
|
void | iso8601_subtract_elapsed (struct iso8601_date *date, const struct iso8601_elapsed *per) |
| Subtract a period from a date. More...
|
|
void | iso8601_add_multiple (struct iso8601_date *date, const struct iso8601_elapsed *per, int n) |
| Add a multiple of a period to a date. More...
|
|
void | iso8601_difference (const struct iso8601_date *d1, const struct iso8601_date *d2, struct iso8601_elapsed *per, int *sign) |
| Find difference between dates. More...
|
|
int | iso8601_elapsed_div (const struct iso8601_elapsed *num, const struct iso8601_elapsed *denom, struct iso8601_elapsed *remain) |
| Divide one period by another. More...
|
|
This set of functions is useful for performing arithmetic etc. on dates. It uses struct iso8601_elapsed to represent the magnitude of time differences.
◆ iso8601_lt()
Comparison (less than).
- Parameters
-
d1 | First date to compare. |
d2 | Second date to compare. |
- Return values
-
non-0 | if d1 < d2 |
0 | otherwise |
◆ iso8601_lte()
Comparison (less than or equal to).
- Parameters
-
d1 | First date to compare. |
d2 | Second date to compare. |
- Return values
-
non-0 | if d1 <= d2 |
0 | otherwise |
◆ iso8601_eq()
Comparison (equality).
- Parameters
-
d1 | First date to compare. |
d2 | Second date to compare. |
- Return values
-
non-0 | if d1 == d2 |
0 | otherwise |
◆ iso8601_cmp()
Comparison (for qsort et al.).
- Parameters
-
d1 | First date to compare. |
d2 | Second date to compare. |
- Return values
-
-1 | if d1 < d2 |
0 | if d1 == d2 |
1 | if d1 > d2 |
◆ iso8601_add_elapsed()
Add a period to a date.
- Parameters
-
[in,out] | date | Date to modify. |
| per | Period to advance date/time by. |
◆ iso8601_subtract_elapsed()
Subtract a period from a date.
- Parameters
-
[in,out] | date | Date to modify. |
| per | Period to regress date/time by. |
◆ iso8601_add_multiple()
Add a multiple of a period to a date.
- Parameters
-
[in,out] | date | Date to modify. |
| per | Period to advance date/time by. |
| n | Multiple of per. |
Adds n multiples of per to date. n may be 0 or negative. The result is stored in date. This is an efficient implementation which avoids loops, but it does use 64-bit arithmetic.
◆ iso8601_difference()
Find difference between dates.
- Parameters
-
| d1 | First date. |
| d2 | Second date. |
[out] | per | Magnitude of period elapsed between two dates. Pointer may be 0. |
[out] | sign | Set to sign of difference (-1 or +1). Pointer may be 0. |
This function will perform the calculation |d1 - d2|
, storing the result in per (if it is not a null pointer). The sign of the result is stored in sign (if it is not a null pointer), i.e. -1 if d2 > d1 or +1 if d2 <= d1.
◆ iso8601_elapsed_div()
Divide one period by another.
- Parameters
-
| num | Numerator. |
| denom | Denominator (divisor). |
[out] | remain | Remainder. May be 0. |
- Returns
- Number of times denom divides into num.
This function computes the number of times that denom can be divided into num, returning that number. If desired, the remaining period which could not be divided can be written into remain. Uses 64-bit arithmetic internally.