GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
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,
15  DateTime * result);
16 
17 /* error.c */
18 int datetime_error(int code, char *msg);
19 int datetime_error_code(void);
20 char *datetime_error_msg(void);
21 void datetime_clear_error(void);
22 
23 /* format.c */
24 int datetime_format(const DateTime * dt, char *buf);
25 
26 /* incr1.c */
27 int datetime_increment(DateTime * src, DateTime * incr);
28 
29 /* incr2.c */
30 int datetime_is_valid_increment(const DateTime * src, const DateTime * incr);
31 int datetime_check_increment(const DateTime * src, const DateTime * incr);
32 
33 /* incr3.c */
34 int datetime_get_increment_type(const DateTime * dt, int *mode, int *from,
35  int *to, int *fracsec);
36 int datetime_set_increment_type(const DateTime * src, DateTime * incr);
37 
38 /* local.c */
39 int datetime_get_local_timezone(int *minutes);
41 
42 /* misc.c */
43 int datetime_days_in_month(int year, int month, int ad);
44 int datetime_is_leap_year(int year, int ad);
45 int datetime_days_in_year(int year, int ad);
46 
47 /* same.c */
48 int datetime_is_same(const DateTime * src, const DateTime * dst);
49 
50 /* scan.c */
51 int datetime_scan(DateTime * dt, const char *buf);
52 
53 /* sign.c */
54 int datetime_is_positive(const DateTime * dt);
55 int datetime_is_negative(const DateTime * dt);
59 
60 /* type.c */
61 int datetime_set_type(DateTime * dt, int mode, int from, int to, int fracsec);
62 int datetime_get_type(const DateTime * dt, int *mode, int *from, int *to,
63  int *fracsec);
64 int datetime_is_valid_type(const DateTime * dt);
65 int datetime_check_type(const DateTime * dt);
68 int datetime_is_absolute(const DateTime * dt);
69 int datetime_is_relative(const DateTime * dt);
70 
71 /* tz1.c */
72 int datetime_check_timezone(const DateTime * dt, int minutes);
73 int datetime_get_timezone(const DateTime * dt, int *minutes);
74 int datetime_set_timezone(DateTime * dt, int minutes);
76 int datetime_is_valid_timezone(int minutes);
77 
78 /* tz2.c */
79 int datetime_change_timezone(DateTime * dt, int minutes);
81 void datetime_decompose_timezone(int tz, int *hours, int *minutes);
82 
83 /* values.c */
84 int datetime_check_year(const DateTime * dt, int year);
85 int datetime_check_month(const DateTime * dt, int month);
86 int datetime_check_day(const DateTime * dt, int day);
87 int datetime_check_hour(const DateTime * dt, int hour);
88 int datetime_check_minute(const DateTime * dt, int minute);
89 int datetime_check_second(const DateTime * dt, double second);
90 int datetime_check_fracsec(const DateTime * dt, int fracsec);
91 int datetime_get_year(const DateTime * dt, int *year);
92 int datetime_set_year(DateTime * dt, int year);
93 int datetime_get_month(const DateTime * dt, int *month);
94 int datetime_set_month(DateTime * dt, int month);
95 int datetime_get_day(const DateTime * dt, int *day);
96 int datetime_set_day(DateTime * dt, int day);
97 int datetime_get_hour(const DateTime * dt, int *hour);
98 int datetime_set_hour(DateTime * dt, int hour);
99 int datetime_get_minute(const DateTime * dt, int *minute);
100 int datetime_set_minute(DateTime * dt, int minute);
101 int datetime_get_second(const DateTime * dt, double *second);
102 int datetime_set_second(DateTime * dt, double second);
103 int datetime_get_fracsec(const DateTime * dt, int *fracsec);
104 int datetime_set_fracsec(DateTime * dt, int fracsec);
105 
106 #endif /* GRASS_DATETIMEDEFS_H */
int datetime_get_timezone(const DateTime *dt, int *minutes)
returns 0 on success
Definition: tz1.c:49
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:42
int datetime_set_fracsec(DateTime *dt, int fracsec)
returns 0 on success or negative value on error
Definition: values.c:530
int datetime_check_type(const DateTime *dt)
checks the mode/from/to/fracsec in dt. Returns:
int datetime_get_local_timezone(int *minutes)
Returns: 0 OK -1 local timezone info not available.
Definition: local.c:33
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:23
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:87
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:60
int datetime_set_second(DateTime *dt, double second)
returns 0 on success or negative value on error
Definition: values.c:486
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_set_day(DateTime *dt, int day)
if dt.mode = ABSOLUTE, then the dt.year, dt.month:
Definition: values.c:354
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:207
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
Definition: incr2.c:21
int datetime_is_relative(const DateTime *dt)
Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)
char * dst
Definition: lz4.h:599
int datetime_get_second(const DateTime *dt, double *second)
returns 0 on success or negative value on error
Definition: values.c:464
int datetime_error_code(void)
returns an error code
int datetime_check_timezone(const DateTime *dt, int minutes)
returns 0 on success
Definition: tz1.c:26
int datetime_in_interval_day_second(int x)
void datetime_set_negative(DateTime *dt)
Makes the DateTime negative. (B.C. for ABSOLUTE DateTimes)
Definition: sign.c:67
#define x
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
Definition: datetime/type.c:80
int datetime_is_between(int x, int a, int b)
Definition: between.c:8
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:24
int datetime_get_minute(const DateTime *dt, int *minute)
returns 0 on success or negative value on error
Definition: values.c:420
int datetime_change_to_utc(DateTime *dt)
Return datetime_change_timezone (dt, 0);.
Definition: tz2.c:63
void datetime_copy(DateTime *src, const DateTime *dst)
Copies the DateTime [into/from ???] src.
Definition: datetime/copy.c:20
int datetime_set_hour(DateTime *dt, int hour)
returns 0 on success or negative value on error
Definition: values.c:398
int datetime_unset_timezone(DateTime *dt)
unsets timezone in 'dt' returns 0
Definition: tz1.c:92
int datetime_set_year(DateTime *dt, int year)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
Definition: values.c:251
int datetime_set_timezone(DateTime *dt, int minutes)
returns 0 on success
Definition: tz1.c:71
void datetime_invert_sign(DateTime *dt)
Definition: sign.c:80
double b
Definition: r_raster.c:39
int datetime_days_in_year(int year, int ad)
returns the number of days in 'year'
Definition: datetime/misc.c:41
int datetime_is_negative(const DateTime *dt)
Returns: 1 if the DateTime is negative 0 otherwise.
Definition: sign.c:37
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:64
void datetime_set_positive(DateTime *dt)
Makes the DateTime positive. (A.D. for ABSOLUTE DateTimes)
Definition: sign.c:52
int datetime_get_year(const DateTime *dt, int *year)
returns 0 on success or negative value on error
Definition: values.c:227
int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
Definition: datetime/type.c:37
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:55
int datetime_set_minute(DateTime *dt, int minute)
returns 0 on success or negative value on error
Definition: values.c:442
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:181
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:29
char * datetime_error_msg(void)
returns an error message
int datetime_get_month(const DateTime *dt, int *month)
returns 0 on success or negative value on error
Definition: values.c:276
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:155
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_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:43
int datetime_get_day(const DateTime *dt, int *day)
returns 0 on success or negative value on error
Definition: values.c:325
int datetime_get_fracsec(const DateTime *dt, int *fracsec)
returns 0 on success or negative value on error
Definition: values.c:508
int datetime_difference(const DateTime *a, const DateTime *b, DateTime *result)
This performs the formula: result = a - b;.
Definition: diff.c:81
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:86
int datetime_set_month(DateTime *dt, int month)
if dt.mode = ABSOLUTE, this also sets dt.day = 0
Definition: values.c:300
int datetime_get_hour(const DateTime *dt, int *hour)
returns 0 on success or negative value on error
Definition: values.c:376
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:129
int datetime_in_interval_year_month(int x)
int datetime_is_positive(const DateTime *dt)
Returns: 1 if the Datetime is positive 0 otherwise.
Definition: sign.c:21
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...
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:111
void datetime_clear_error(void)
clears error code and message
int datetime_is_leap_year(int year, int ad)
Definition: datetime/misc.c:18
int datetime_change_from_to(DateTime *dt, int from, int to, int round)
Changes the from/to of the type for dt. The &#39;from/to&#39; must be legal values for the mode of dt; (if th...
Definition: change.c:55
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:91
int datetime_increment(DateTime *src, DateTime *incr)
This function changes the &#39;src&#39; date/time data based on the &#39;incr&#39; The type (mode/from/to) of the &#39;sr...
Definition: incr1.c:67
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:87
int datetime_get_type(const DateTime *dt, int *mode, int *from, int *to, int *fracsec)
Definition: datetime/type.c:58