GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
defs/datetime.h
Go to the documentation of this file.
1 #ifndef GRASS_DATETIMEDEFS_H
2 #define GRASS_DATETIMEDEFS_H
3 
4 /* between.c */
5 int datetime_is_between(int x, int a, int b);
6 
7 /* change.c */
8 int datetime_change_from_to(DateTime *dt, int from, int to, int round);
9 
10 /* copy.c */
11 void datetime_copy(DateTime *src, const DateTime *dst);
12 
13 /* diff.c */
14 int datetime_difference(const DateTime *a, const DateTime *b, DateTime *result);
15 
16 /* error.c */
17 int datetime_error(int code, char *msg);
18 int datetime_error_code(void);
19 char *datetime_error_msg(void);
20 void datetime_clear_error(void);
21 
22 /* format.c */
23 int datetime_format(const DateTime *dt, char *buf);
24 
25 /* incr1.c */
27 
28 /* incr2.c */
29 int datetime_is_valid_increment(const DateTime *src, const DateTime *incr);
30 int datetime_check_increment(const DateTime *src, const DateTime *incr);
31 
32 /* incr3.c */
33 int datetime_get_increment_type(const DateTime *dt, int *mode, int *from,
34  int *to, int *fracsec);
36 
37 /* local.c */
38 int datetime_get_local_timezone(int *minutes);
40 
41 /* misc.c */
42 int datetime_days_in_month(int year, int month, int ad);
43 int datetime_is_leap_year(int year, int ad);
44 int datetime_days_in_year(int year, int ad);
45 
46 /* same.c */
47 int datetime_is_same(const DateTime *src, const DateTime *dst);
48 
49 /* scan.c */
50 int datetime_scan(DateTime *dt, const char *buf);
51 
52 /* sign.c */
53 int datetime_is_positive(const DateTime *dt);
54 int datetime_is_negative(const DateTime *dt);
58 
59 /* type.c */
60 int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec);
61 int datetime_get_type(const DateTime *dt, int *mode, int *from, int *to,
62  int *fracsec);
63 int datetime_is_valid_type(const DateTime *dt);
64 int datetime_check_type(const DateTime *dt);
67 int datetime_is_absolute(const DateTime *dt);
68 int datetime_is_relative(const DateTime *dt);
69 
70 /* tz1.c */
71 int datetime_check_timezone(const DateTime *dt, int minutes);
72 int datetime_get_timezone(const DateTime *dt, int *minutes);
73 int datetime_set_timezone(DateTime *dt, int minutes);
75 int datetime_is_valid_timezone(int minutes);
76 
77 /* tz2.c */
78 int datetime_change_timezone(DateTime *dt, int minutes);
80 void datetime_decompose_timezone(int tz, int *hours, int *minutes);
81 
82 /* values.c */
83 int datetime_check_year(const DateTime *dt, int year);
84 int datetime_check_month(const DateTime *dt, int month);
85 int datetime_check_day(const DateTime *dt, int day);
86 int datetime_check_hour(const DateTime *dt, int hour);
87 int datetime_check_minute(const DateTime *dt, int minute);
88 int datetime_check_second(const DateTime *dt, double second);
89 int datetime_check_fracsec(const DateTime *dt, int fracsec);
90 int datetime_get_year(const DateTime *dt, int *year);
91 int datetime_set_year(DateTime *dt, int year);
92 int datetime_get_month(const DateTime *dt, int *month);
93 int datetime_set_month(DateTime *dt, int month);
94 int datetime_get_day(const DateTime *dt, int *day);
95 int datetime_set_day(DateTime *dt, int day);
96 int datetime_get_hour(const DateTime *dt, int *hour);
97 int datetime_set_hour(DateTime *dt, int hour);
98 int datetime_get_minute(const DateTime *dt, int *minute);
99 int datetime_set_minute(DateTime *dt, int minute);
100 int datetime_get_second(const DateTime *dt, double *second);
101 int datetime_set_second(DateTime *dt, double second);
102 int datetime_get_fracsec(const DateTime *dt, int *fracsec);
103 int datetime_set_fracsec(DateTime *dt, int fracsec);
104 
105 #endif /* GRASS_DATETIMEDEFS_H */
int datetime_is_valid_timezone(int minutes)
Returns: 1 OK: -720 <= minutes <= 780 (720 = 12 hours; 780 = 13 hours) 0 NOT OK.
Definition: tz1.c:106
int datetime_set_fracsec(DateTime *dt, int fracsec)
returns 0 on success or negative value on error
Definition: values.c:508
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...
Definition: incr2.c:58
int datetime_is_negative(const DateTime *dt)
Returns: 1 if the DateTime is negative 0 otherwise.
Definition: sign.c:36
int datetime_change_to_utc(DateTime *dt)
Return datetime_change_timezone (dt, 0);.
Definition: tz2.c:59
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
Definition: values.c:445
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.
Definition: values.c:27
int datetime_get_fracsec(const DateTime *dt, int *fracsec)
returns 0 on success or negative value on error
Definition: values.c:487
int datetime_is_positive(const DateTime *dt)
Returns: 1 if the Datetime is positive 0 otherwise.
Definition: sign.c:20
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,...
Definition: scan.c:41
void datetime_set_negative(DateTime *dt)
Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)
Definition: sign.c:64
int datetime_get_timezone(const DateTime *dt, int *minutes)
returns 0 on success
Definition: tz1.c:46
int datetime_difference(const DateTime *a, const DateTime *b, DateTime *result)
This performs the formula: result = a - b;.
Definition: diff.c:79
int datetime_unset_timezone(DateTime *dt)
unsets timezone in 'dt' returns 0
Definition: tz1.c:88
int datetime_get_type(const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
Definition: datetime/type.c:56
int datetime_set_day(DateTime *dt, int day)
if dt.mode = ABSOLUTE, then the dt.year, dt.month:
Definition: values.c:340
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
Definition: datetime/type.c:77
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...
Definition: tz2.c:21
void datetime_get_local_time(DateTime *dt)
set mode/from/to ABSOLUTE/YEAR/SECOND set the local time into 'dt' does not set timezone.
Definition: local.c:82
int datetime_days_in_month(int year, int month, int ad)
returns number of days in 'month' of a particular 'year'
Definition: datetime/misc.c:61
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....
Definition: values.c:87
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...
Definition: incr3.c:41
int datetime_error_code(void)
returns an error code
int datetime_is_between(int x, int a, int b)
Definition: between.c:8
int datetime_set_month(DateTime *dt, int month)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
Definition: values.c:288
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
Definition: values.c:199
int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
Definition: datetime/type.c:36
void datetime_set_positive(DateTime *dt)
Makes the DateTime positive. (A.D. for ABSOLUTE DateTimes)
Definition: sign.c:50
int datetime_is_same(const DateTime *src, const DateTime *dst)
Returns: 1 if 'src' is exactly the same as 'dst' 0 if they differ.
Definition: same.c:22
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.
Definition: values.c:52
int datetime_get_hour(const DateTime *dt, int *hour)
returns 0 on success or negative value on error
Definition: values.c:361
int datetime_get_year(const DateTime *dt, int *year)
returns 0 on success or negative value on error
Definition: values.c:218
int datetime_get_local_timezone(int *minutes)
Returns: 0 OK -1 local timezone info not available.
Definition: local.c:29
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
Definition: values.c:149
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
Definition: tz1.c:67
int datetime_set_hour(DateTime *dt, int hour)
returns 0 on success or negative value on error
Definition: values.c:382
void datetime_invert_sign(DateTime *dt)
Definition: sign.c:76
int datetime_set_year(DateTime *dt, int year)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
Definition: values.c:241
int datetime_get_minute(const DateTime *dt, int *minute)
returns 0 on success or negative value on error
Definition: values.c:403
int datetime_set_second(DateTime *dt, double second)
returns 0 on success or negative value on error
Definition: values.c:466
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
Definition: incr2.c:20
int datetime_check_timezone(const DateTime *dt, int minutes)
returns 0 on success
Definition: tz1.c:24
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...
Definition: incr1.c:68
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...
Definition: change.c:54
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)
Definition: datetime/misc.c:17
int datetime_get_day(const DateTime *dt, int *day)
returns 0 on success or negative value on error
Definition: values.c:312
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
Definition: values.c:124
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
Definition: values.c:424
int datetime_set_increment_type(const DateTime *src, DateTime *incr)
src must be legal This is a convenience routine which is implemented as follows:
Definition: incr3.c:84
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
Definition: values.c:174
int datetime_get_month(const DateTime *dt, int *month)
returns 0 on success or negative value on error
Definition: values.c:265
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'
Definition: datetime/misc.c:39
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...
Definition: tz2.c:82
int datetime_in_interval_year_month(int x)
void datetime_copy(DateTime *src, const DateTime *dst)
Copies the DateTime [into/from ???] src.
Definition: datetime/copy.c:20
char * dst
Definition: lz4.h:981
const char * src
Definition: lz4.h:989
double b
Definition: r_raster.c:39
#define x