7 #include <grass/datetime.h>
10 static int have(
int x,
const DateTime * dt)
31 if (!have(DATETIME_YEAR, dt))
57 if (!have(DATETIME_MONTH, dt))
96 if (!have(DATETIME_DAY, dt))
131 if (!have(DATETIME_HOUR, dt))
135 if (dt->from != DATETIME_HOUR && hour > 23)
157 if (!have(DATETIME_MINUTE, dt))
161 if (dt->from != DATETIME_MINUTE && minute > 59)
183 if (!have(DATETIME_SECOND, dt))
187 if (dt->from != DATETIME_SECOND && second >= 60.0)
209 if (!have(DATETIME_SECOND, dt))
426 *minute = dt->minute;
470 *second = dt->second;
514 *fracsec = dt->fracsec;
536 dt->fracsec = fracsec;
int datetime_set_hour(DateTime *dt, int hour)
returns 0 on success or negative value on error
int datetime_get_month(const DateTime *dt, int *month)
returns 0 on success or negative value on error
int datetime_check_month(const DateTime *dt, int month)
Returns: 0 is legal month for dt -1 illegal month for this dt -2 dt has no month component.
int datetime_check_second(const DateTime *dt, double second)
returns: 0 on success -1 if 'dt' has an invalid second -2 if 'dt' has no second
int datetime_set_day(DateTime *dt, int day)
if dt.mode = ABSOLUTE, then the dt.year, dt.month:
int datetime_set_year(DateTime *dt, int year)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
int datetime_get_second(const DateTime *dt, double *second)
returns 0 on success or negative value on error
int datetime_check_year(const DateTime *dt, int year)
Returns: 0 is legal year for dt -1 illegal year for this dt -2 dt has no year component.
int datetime_is_positive(const DateTime *dt)
Returns: 1 if the Datetime is positive 0 otherwise.
int datetime_check_day(const DateTime *dt, int day)
Returns: 0 is legal day for dt -1 illegal day for this dt -2 dt has no day component Note: if dt...
int datetime_get_day(const DateTime *dt, int *day)
returns 0 on success or negative value on error
int datetime_get_year(const DateTime *dt, int *year)
returns 0 on success or negative value on error
int datetime_is_between(int x, int a, int b)
int datetime_set_fracsec(DateTime *dt, int fracsec)
returns 0 on success or negative value on error
int datetime_check_fracsec(const DateTime *dt, int fracsec)
returns: 0 on success -1 if 'dt' has an invalid fracsec -2 if 'dt' has no fracsec ...
int datetime_set_month(DateTime *dt, int month)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
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_set_second(DateTime *dt, double second)
returns 0 on success or negative value on error
int datetime_get_hour(const DateTime *dt, int *hour)
returns 0 on success or negative value on error
int datetime_get_fracsec(const DateTime *dt, int *fracsec)
returns 0 on success or negative value on error
int datetime_error(int code, char *msg)
record 'code' and 'msg' as error code/msg (in static variables) code==0 will clear the error (ie set ...
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_get_minute(const DateTime *dt, int *minute)
returns 0 on success or negative value on error
int datetime_set_minute(DateTime *dt, int minute)
returns 0 on success or negative value on error
int datetime_days_in_month(int year, int month, int ad)
returns number of days in 'month' of a particular 'year'
int datetime_check_hour(const DateTime *dt, int hour)
returns: 0 on success -1 if 'dt' has an invalid hour -2 if 'dt' has no hour
int datetime_check_minute(const DateTime *dt, int minute)
returns: 0 on success -1 if 'dt' has an invalid minute -2 if 'dt' has no minute