GRASS GIS 7 Programmer's Manual  7.0.5(2016)-r00000
incr3.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1995. Bill Brown <brown@gis.uiuc.edu> & Michael Shapiro
3  *
4  * This program is free software under the GPL (>=v2)
5  * Read the file GPL.TXT coming with GRASS for details.
6  */
7 #include <grass/datetime.h>
8 
41 int
42 datetime_get_increment_type(const DateTime * dt, int *mode, int *from,
43  int *to, int *fracsec)
44 {
45  if (!datetime_is_valid_type(dt))
46  return datetime_error_code();
47 
48  *mode = DATETIME_RELATIVE;
49  *to = dt->to;
50  *fracsec = dt->fracsec;
51 
52  if (datetime_is_absolute(dt)) {
54  *from = DATETIME_YEAR;
55  else
56  *from = DATETIME_DAY;
57  }
58  else {
59  *from = dt->from;
60  }
61  return 0;
62 }
63 
64 
86 int datetime_set_increment_type(const DateTime * src, DateTime * incr)
87 {
88  int mode, from, to, fracsec;
89 
90  if (datetime_get_increment_type(src, &mode, &from, &to, &fracsec) != 0)
91  return datetime_error_code();
92  return datetime_set_type(incr, mode, from, to, fracsec);
93 }
int datetime_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
Definition: type.c:80
int datetime_error_code(void)
returns an error code
int datetime_in_interval_year_month(int x)
Definition: type.c:151
int datetime_is_absolute(const DateTime *dt)
Returns: 1 if dt.mode is absolute 0 if not (even if dt.mode is not defined)
Definition: type.c:173
int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
Definition: type.c:37
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_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