GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 
21 int datetime_is_valid_increment(const DateTime * src, const DateTime * incr)
22 {
23  return datetime_check_increment(src, incr) == 0;
24 }
25 
26 
27 
60 int datetime_check_increment(const DateTime * src, const DateTime * incr)
61 {
62  if (!datetime_is_valid_type(src))
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 
72  if (datetime_in_interval_year_month(src->to) &&
74  return datetime_error(-3, "illegal datetime increment interval");
75 
76  if (datetime_in_interval_day_second(src->to) &&
78  return datetime_error(-4, "illegal datetime increment interval");
79 
80  return 0;
81 }
int datetime_check_increment(const DateTime *src, const DateTime *incr)
This checks if the type of &#39;incr&#39; is valid for incrementing/decrementing &#39;src&#39;. The type (mode/from/t...
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 datetime_in_interval_day_second(int x)
int datetime_is_relative(const DateTime *dt)
Returns: 1 if dt.mode is relative 0 if not (even if dt.mode is not defined)
int datetime_error(int code, char *msg)
record &#39;code&#39; and &#39;msg&#39; as error code/msg (in static variables) code==0 will clear the error (ie set ...
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_in_interval_year_month(int x)