14 static double _debug_decimal(
DateTime * dt)
23 dtdec = dt->
day / 365.25 +
101 for (i = incr->
to; i >= incr->
from; i--) {
102 _datetime_add_field(dt, incr, i);
108 for (i = incr->
to; i >= incr->
from; i--) {
109 _datetime_subtract_field(dt, incr, i);
118 _datetime_subtract_field(dt, incr, i);
125 _datetime_add_field(dt, incr, i);
171 borrow = 1 + (incr->
second -
src->second - 1) / 60;
174 borrow = 1 + (incr->
second -
src->second) / 60;
175 src->second += borrow * 60;
186 borrow = 1 + (incr->
minute -
src->minute - 1) / 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;
256 borrow = 1 + (incr->
second -
src->second - 1) / 60;
257 src->second += borrow * 60;
268 borrow = 1 + (incr->
minute -
src->minute - 1) / 60;
269 src->minute += borrow * 60;
273 srcinc.
hour = borrow;
280 borrow = 1 + (incr->
hour -
src->hour - 1) / 24;
281 src->hour += borrow * 24;
292 if (
src->day <= incr->
day) {
299 while (newdays <= incr->day) {
316 srcinc.
month = borrow;
323 borrow = 1 + (incr->
month -
src->month) / 12;
324 src->month += borrow * 12;
328 srcinc.
year = borrow;
348 for (i =
src->month - 1; i > 0; i--) {
360 src->hour =
src->minute = 0;
378 static int _datetime_carry(
DateTime *dt,
int absolute)
400 if (dt->
hour >= 24) {
401 carry = dt->
hour / 24;
403 dt->
hour -= carry * 24;
418 if (dt->
month > 12) {
419 carry = (dt->
month - 1) / 12;
423 dt->
month -= carry * 12;
430 if (dt->
month >= 12) {
431 carry = dt->
month / 12;
433 dt->
month -= carry * 12;
445 if (dt->
month == 12) {
493 _datetime_carry(
src, 1);
495 _datetime_carry(
src, 0);
#define DATETIME_ABSOLUTE
#define DATETIME_RELATIVE
int datetime_in_interval_day_second(int x)
int datetime_days_in_month(int year, int month, int ad)
returns number of days in 'month' of a particular 'year'
int datetime_error_code(void)
returns an error code
void datetime_invert_sign(DateTime *dt)
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
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...
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)
void datetime_copy(DateTime *src, const DateTime *dst)
Copies the DateTime [into/from ???] src.
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...