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)  

incr2.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/*!
11 * \brief
12 *
13 * Returns:
14 * <b>datetime_check_increment</b>(src, incr) == 0
15 *
16 * \param src
17 * \param incr
18 * \return int
19 */
20
22{
23 return datetime_check_increment(src, incr) == 0;
24}
25
26
27
28/*!
29 * \brief
30 *
31 * This checks if the type of 'incr' is valid for incrementing/decrementing 'src'.
32 * The type (mode/from/to) of the 'src' can be anything.
33 * The incr.mode must be RELATIVE
34 * A timezone in 'src' is allowed - it's presence is ignored.
35 * To aid in setting the 'incr' type, see <b>datetime_get_increment_type()</b>.
36 * Returns:
37 * <ul>
38 <li> 0 valid increment
39 </li>
40 <li> 1 src is not a legal DateTime, error code/msg are those set by
41 * <b>datetime_is_valid_type()</b>
42 </li>
43 <li> 2 incr is not a legal DateTime, error code/msg are those set by
44 * <b>datetime_is_valid_type()</b>
45 </li>
46 <li> -1 incr.mode not relative
47 </li>
48 <li> -2 incr more precise that src
49 </li>
50 <li> -3 illegal incr, must be YEAR-MONTH
51 </li>
52 <li> -4 illegal incr, must be DAY-SECOND
53 </li></ul>
54 *
55 * \param src
56 * \param incr
57 * \return int
58 */
59
61{
63 return 1;
64 if (!datetime_is_valid_type(incr))
65 return 2;
66
67 if (!datetime_is_relative(incr))
68 return datetime_error(-1, "datetime increment mode not relative");
69 if (incr->to > src->to)
70 return datetime_error(-2, "datetime increment too precise");
71
74 return datetime_error(-3, "illegal datetime increment interval");
75
78 return datetime_error(-4, "illegal datetime increment interval");
79
80 return 0;
81}
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 ...
Definition: error.c:30
int datetime_in_interval_day_second(int x)
Definition: type.c:156
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_relative(const DateTime *dt)
Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)
Definition: type.c:190
int datetime_in_interval_year_month(int x)
Definition: type.c:151
static int src[2][2]
Definition: raster.c:25
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...
Definition: incr2.c:60
int datetime_is_valid_increment(const DateTime *src, const DateTime *incr)
Returns: datetime_check_increment(src, incr) == 0.
Definition: incr2.c:21
int to
Definition: datetime.h:20