7 #include <grass/datetime.h>
9 static void make_incr(DateTime *,
int,
int, DateTime *);
83 for (pos = dtfrom; pos < from; pos++) {
86 dt->month += dt->year * 12;
90 dt->hour += dt->day * 24;
94 dt->minute += dt->hour * 60;
98 dt->second += dt->minute * 60.0;
114 for (carry = 0, pos = dt->to; carry == 0 && pos > to; pos--) {
128 case DATETIME_MINUTE:
132 case DATETIME_SECOND:
140 make_incr(&incr, to, to, dt);
160 for (pos = dt->to; pos > to; pos--) {
161 make_incr(&incr, pos, pos, dt);
163 incr.year = dt->year;
164 incr.month = dt->month;
165 incr.day = dt->day + ndays / 2;
166 incr.hour = dt->hour;
167 incr.minute = dt->minute;
168 incr.second = dt->second;
171 if (ndays > 0 && pos == DATETIME_DAY)
178 for (pos = from; pos < dtfrom; pos++)
192 case DATETIME_MINUTE:
195 case DATETIME_SECOND:
200 for (pos = to; pos > dt->to; pos--)
214 case DATETIME_MINUTE:
217 case DATETIME_SECOND:
223 if (dt->to < DATETIME_SECOND)
232 static void make_incr(DateTime *incr,
int from,
int to, DateTime *dt)
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_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_days_in_year(int year, int ad)
returns the number of days in 'year'
int datetime_is_negative(const DateTime *dt)
Returns: 1 if the DateTime is negative 0 otherwise.
void datetime_set_negative(DateTime *dt)
Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
int datetime_is_absolute(const DateTime *dt)
Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined)
int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
int datetime_is_relative(const DateTime *dt)
Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)