7 #include <grass/datetime.h>
9 static void make_incr();
84 for (pos = dtfrom; pos < from; pos++) {
87 dt->month += dt->year * 12;
91 dt->hour += dt->day * 24;
95 dt->minute += dt->hour * 60;
99 dt->second += dt->minute * 60.0;
115 for (carry = 0, pos = dt->to; carry == 0 && pos > to; pos--) {
129 case DATETIME_MINUTE:
133 case DATETIME_SECOND:
141 make_incr(&incr, to, to, dt);
161 for (pos = dt->to; pos > to; pos--) {
162 make_incr(&incr, pos, pos, dt);
164 incr.year = dt->year;
165 incr.month = dt->month;
166 incr.day = dt->day + ndays / 2;
167 incr.hour = dt->hour;
168 incr.minute = dt->minute;
169 incr.second = dt->second;
172 if (ndays > 0 && pos == DATETIME_DAY)
179 for (pos = from; pos < dtfrom; pos++)
193 case DATETIME_MINUTE:
196 case DATETIME_SECOND:
201 for (pos = to; pos > dt->to; pos--)
215 case DATETIME_MINUTE:
218 case DATETIME_SECOND:
224 if (dt->to < DATETIME_SECOND)
233 static void make_incr(DateTime * incr,
int from,
int to, DateTime * dt)
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_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
int datetime_days_in_year(int year, int ad)
returns the number of days in 'year'
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_is_relative(const DateTime *dt)
Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)
int datetime_is_absolute(const DateTime *dt)
Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined)
void datetime_set_negative(DateTime *dt)
Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)
int datetime_is_negative(const DateTime *dt)
Returns: 1 if the DateTime is negative 0 otherwise.
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.