grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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
9/*!
10 * \brief
11 *
12 * This returns the components of a type
13 * (mode/from/to/fracsec) that can be used to construct a DateTime object that
14 * can be used to increment the 'src'. Also see
15 * <b>datetime_set_increment_type()</b>.
16 * returns:
17 * 0 dt is legal
18 * !=0 why dt is illegal
19 * Implemented as follows:
20 \code
21 *mode = RELATIVE
22 *to = src.to
23 *fracsec = src.fracsec
24 if src.mode is ABSOLUTE
25 if src.to is in {YEAR,MONTH} then
26 *from = YEAR
27 if src.to is in {DAY,HOUR,MINUTE,SECOND} then
28 *from = DAY
29 if src.mode is RELATIVE, then
30 *from = src.from
31 \endcode
32 *
33 * \param dt
34 * \param mode
35 * \param from
36 * \param to
37 * \param fracsec
38 * \return int
39 */
40
41int
42datetime_get_increment_type(const DateTime * dt, int *mode, int *from,
43 int *to, int *fracsec)
44{
46 return datetime_error_code();
47
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
65/*!
66 * \brief
67 *
68 * src must be legal
69 * This is a convenience routine which is implemented as follows:
70 \code
71 int mode, from ,to;
72 int fracsec;
73 if(<b>datetime_get_increment_type</b>(src, &mode, &from, &to, &fracsec))
74 return <b>datetime_get_error_code()</b>;
75 return <b>datetime_set_type</b> (incr, mode, from, to, fracsec);
76 \endcode
77 * Timezone Timezones are represented in minutes from GMT in the range
78 * [-720,+780]. For a DateTime to have a timezone, it must be of type ABSOLUTE,
79 * and "to" must be in {MINUTE,SECOND}.
80 *
81 * \param src
82 * \param incr
83 * \return int
84 */
85
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_error_code(void)
returns an error code
Definition: error.c:48
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_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_in_interval_year_month(int x)
Definition: type.c:151
#define DATETIME_DAY
Definition: datetime.h:12
#define DATETIME_RELATIVE
Definition: datetime.h:5
#define DATETIME_YEAR
Definition: datetime.h:10
static int src[2][2]
Definition: raster.c:25
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
int to
Definition: datetime.h:20
int fracsec
Definition: datetime.h:21
int from
Definition: datetime.h:20
static double mode(double *value, int argc)
Definition: xmode.c:25