GRASS Programmer's Manual  6.4.2(2012)
tz1.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 
00009 
00010 static int have(int x, const DateTime * dt)
00011 {
00012     return datetime_is_between(x, dt->from, dt->to);
00013 }
00014 
00015 
00026 int datetime_check_timezone(const DateTime * dt, int minutes)
00027 {
00028     if (!datetime_is_absolute(dt))
00029         return datetime_error(-1, "datetime not absolute");
00030     if (!have(DATETIME_MINUTE, dt))
00031         return datetime_error(-2, "datetime has no minute");
00032     if (!datetime_is_valid_timezone(minutes))
00033         return datetime_error(-3, "invalid datetime timezone");
00034 
00035     return 0;
00036 }
00037 
00038 
00049 int datetime_get_timezone(const DateTime * dt, int *minutes)
00050 {
00051     int stat;
00052 
00053     stat = datetime_check_timezone(dt, dt->tz);
00054     if (stat == 0)
00055         *minutes = dt->tz;
00056 
00057     return stat;
00058 }
00059 
00060 
00071 int datetime_set_timezone(DateTime * dt, int minutes)
00072 {
00073     int stat;
00074 
00075     stat = datetime_check_timezone(dt, minutes);
00076     if (stat == 0)
00077         dt->tz = minutes;
00078 
00079     return stat;
00080 }
00081 
00092 int datetime_unset_timezone(DateTime * dt)
00093 {
00094     dt->tz = -9999;
00095 
00096     return 0;
00097 }
00098 
00099 
00111 int datetime_is_valid_timezone(int minutes)
00112 {
00113     return (minutes >= -720 && minutes <= 780);
00114 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines