GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 
40 int
41 datetime_get_increment_type(const DateTime * dt, int *mode, int *from,
42  int *to, int *fracsec)
43 {
44  if (!datetime_is_valid_type(dt))
45  return datetime_error_code();
46 
47  *mode = DATETIME_RELATIVE;
48  *to = dt->to;
49  *fracsec = dt->fracsec;
50 
51  if (datetime_is_absolute(dt)) {
53  *from = DATETIME_YEAR;
54  else
55  *from = DATETIME_DAY;
56  }
57  else {
58  *from = dt->from;
59  }
60  return 0;
61 }
62 
63 
85 int datetime_set_increment_type(const DateTime * src, DateTime * incr)
86 {
87  int mode, from, to, fracsec;
88 
89  if (datetime_get_increment_type(src, &mode, &from, &to, &fracsec) != 0)
90  return datetime_error_code();
91  return datetime_set_type(incr, mode, from, to, fracsec);
92 }
int datetime_set_type(DateTime *dt, int mode, int from, int to, int fracsec)
Definition: datetime/type.c:37
int datetime_error_code(void)
returns an error code
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_is_valid_type(const DateTime *dt)
Returns: 1 if datetime_check_type() returns 0 0 if not.
Definition: datetime/type.c:80
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_in_interval_year_month(int x)
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:85
tuple mode
Definition: tools.py:1481