GRASS Programmer's Manual  6.4.2(2012)
incr3.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995.  Bill Brown <brown@gis.uiuc.edu> & Michael Shapiro
00003  *
00004  * This program is free software under the GPL (>=v2)
00005  * Read the file GPL.TXT coming with GRASS for details.
00006  */
00007 #include <grass/datetime.h>
00008 
00040 int
00041 datetime_get_increment_type(const DateTime * dt, int *mode, int *from,
00042                             int *to, int *fracsec)
00043 {
00044     if (!datetime_is_valid_type(dt))
00045         return datetime_error_code();
00046 
00047     *mode = DATETIME_RELATIVE;
00048     *to = dt->to;
00049     *fracsec = dt->fracsec;
00050 
00051     if (datetime_is_absolute(dt)) {
00052         if (datetime_in_interval_year_month(dt->to))
00053             *from = DATETIME_YEAR;
00054         else
00055             *from = DATETIME_DAY;
00056     }
00057     else {
00058         *from = dt->from;
00059     }
00060     return 0;
00061 }
00062 
00063 
00085 int datetime_set_increment_type(const DateTime * src, DateTime * incr)
00086 {
00087     int mode, from, to, fracsec;
00088 
00089     if (datetime_get_increment_type(src, &mode, &from, &to, &fracsec) != 0)
00090         return datetime_error_code();
00091     return datetime_set_type(incr, mode, from, to, fracsec);
00092 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines