14 static double _debug_decimal(
DateTime * dt)
23 dtdec = dt->
day / 365.25 +
100 for (i = incr->
to; i >= incr->
from; i--) {
101 _datetime_add_field(dt, incr, i);
107 for (i = incr->
to; i >= incr->
from; i--) {
108 _datetime_subtract_field(dt, incr, i);
117 _datetime_subtract_field(dt, incr, i);
124 _datetime_add_field(dt, incr, i);
175 src->
second += borrow * 60;
187 src->
minute += borrow * 60;
191 srcinc.
hour = borrow;
198 borrow = 1 + (incr->
hour - src->
hour - 1) / 24;
199 src->
hour += borrow * 24;
209 if (src->
day < incr->
day) {
224 borrow = 1 + (incr->
month - src->
month - 1) / 12;
225 src->
month += borrow * 12;
229 srcinc.
year = borrow;
250 int i, newdays, borrow = 0;
258 src->
second += borrow * 60;
270 src->
minute += borrow * 60;
274 srcinc.
hour = borrow;
281 borrow = 1 + (incr->
hour - src->
hour - 1) / 24;
282 src->
hour += borrow * 24;
293 if (src->
day <= incr->
day) {
300 while (newdays <= incr->day) {
317 srcinc.
month = borrow;
325 src->
month += borrow * 12;
329 srcinc.
year = borrow;
349 for (i = src->
month - 1; i > 0; i--) {
380 static int _datetime_carry(
DateTime * dt,
int absolute)
402 if (dt->
hour >= 24) {
403 carry = dt->
hour / 24;
405 dt->
hour -= carry * 24;
420 if (dt->
month > 12) {
421 carry = (dt->
month - 1) / 12;
425 dt->
month -= carry * 12;
432 if (dt->
month >= 12) {
433 carry = dt->
month / 12;
435 dt->
month -= carry * 12;
448 if (dt->
month == 12) {
496 _datetime_carry(src, 1);
498 _datetime_carry(src, 0);
int datetime_increment(DateTime *src, DateTime *incr)
This function changes the 'src' date/time data based on the 'incr' The type (mode/from/to) of the 'sr...
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
int datetime_error_code(void)
returns an error code
int datetime_in_interval_day_second(int x)
#define DATETIME_RELATIVE
void datetime_copy(DateTime *src, const DateTime *dst)
Copies the DateTime [into/from ???] src.
void datetime_invert_sign(DateTime *dt)
int datetime_days_in_month(int year, int month, int ad)
returns number of days in 'month' of a particular 'year'
int datetime_set_increment_type(const DateTime *src, DateTime *incr)
src must be legal This is a convenience routine which is implemented as follows:
int datetime_in_interval_year_month(int x)
#define DATETIME_ABSOLUTE
int datetime_change_from_to(DateTime *dt, int from, int to, int round)
Changes the from/to of the type for dt. The 'from/to' must be legal values for the mode of dt; (if th...