1 #ifndef GRASS_DATETIMEDEFS_H
2 #define GRASS_DATETIMEDEFS_H
34 int *to,
int *fracsec);
int datetime_is_valid_timezone(int minutes)
Returns: 1 OK: -720 <= minutes <= 780 (720 = 12 hours; 780 = 13 hours) 0 NOT OK.
int datetime_set_fracsec(DateTime *dt, int fracsec)
returns 0 on success or negative value on error
int datetime_check_increment(const DateTime *src, const DateTime *incr)
This checks if the type of 'incr' is valid for incrementing/decrementing 'src'. The type (mode/from/t...
int datetime_is_negative(const DateTime *dt)
Returns: 1 if the DateTime is negative 0 otherwise.
int datetime_change_to_utc(DateTime *dt)
Return datetime_change_timezone (dt, 0);.
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_in_interval_day_second(int x)
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_get_fracsec(const DateTime *dt, int *fracsec)
returns 0 on success or negative value on error
int datetime_is_positive(const DateTime *dt)
Returns: 1 if the Datetime is positive 0 otherwise.
int datetime_scan(DateTime *dt, const char *buf)
Convert the ascii string into a DateTime. This determines the mode/from/to based on the string,...
void datetime_set_negative(DateTime *dt)
Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)
int datetime_get_timezone(const DateTime *dt, int *minutes)
returns 0 on success
int datetime_difference(const DateTime *a, const DateTime *b, DateTime *result)
This performs the formula: result = a - b;.
int datetime_unset_timezone(DateTime *dt)
unsets timezone in 'dt' returns 0
int datetime_get_type(const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
int datetime_set_day(DateTime *dt, int day)
if dt.mode = ABSOLUTE, then the dt.year, dt.month:
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
int datetime_change_timezone(DateTime *dt, int minutes)
if dt has a timezone, increment dt by minutes-dt.tz MINUTES and set dt.tz = minutes Returns: 0 OK dat...
void datetime_get_local_time(DateTime *dt)
set mode/from/to ABSOLUTE/YEAR/SECOND set the local time into 'dt' does not set timezone.
int datetime_days_in_month(int year, int month, int ad)
returns number of days in 'month' of a particular 'year'
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_increment_type(const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
This returns the components of a type (mode/from/to/fracsec) that can be used to construct a DateTime...
int datetime_error_code(void)
returns an error code
int datetime_is_between(int x, int a, int b)
int datetime_set_month(DateTime *dt, int month)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
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_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_type(DateTime *dt, int mode, int from, int to, int fracsec)
void datetime_set_positive(DateTime *dt)
Makes the DateTime positive. (A.D. for ABSOLUTE DateTimes)
int datetime_is_same(const DateTime *src, const DateTime *dst)
Returns: 1 if 'src' is exactly the same as 'dst' 0 if they differ.
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_get_hour(const DateTime *dt, int *hour)
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_get_local_timezone(int *minutes)
Returns: 0 OK -1 local timezone info not available.
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
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_timezone(DateTime *dt, int minutes)
returns 0 on success
int datetime_set_hour(DateTime *dt, int hour)
returns 0 on success or negative value on error
void datetime_invert_sign(DateTime *dt)
int datetime_set_year(DateTime *dt, int year)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
int datetime_get_minute(const DateTime *dt, int *minute)
returns 0 on success or negative value on error
int datetime_set_second(DateTime *dt, double second)
returns 0 on success or negative value on error
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
int datetime_check_timezone(const DateTime *dt, int minutes)
returns 0 on success
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_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_check_type(const DateTime *dt)
checks the mode/from/to/fracsec in dt. Returns:
int datetime_is_leap_year(int year, int ad)
int datetime_get_day(const DateTime *dt, int *day)
returns 0 on success or negative value on error
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
void datetime_clear_error(void)
clears error code and message
int datetime_set_minute(DateTime *dt, int minute)
returns 0 on success or negative value on error
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_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_get_month(const DateTime *dt, int *month)
returns 0 on success or negative value on error
char * datetime_error_msg(void)
returns an error message
int datetime_days_in_year(int year, int ad)
returns the number of days in 'year'
int datetime_format(const DateTime *dt, char *buf)
formats DateTime structure as a human-readable string returns 0 when successful and 'buf' is filled w...
void datetime_decompose_timezone(int tz, int *hours, int *minutes)
tz = abs(tz) *hour = tz/60 *minute = tz%60 Note: hour,minute are non-negative. Must look at sign of t...
int datetime_in_interval_year_month(int x)
void datetime_copy(DateTime *src, const DateTime *dst)
Copies the DateTime [into/from ???] src.