GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
interval.c
Go to the documentation of this file.
1
/*!
2
\file lib/db/dbmi_base/interval.c
3
4
\brief DBMI Library (base) - range, interval procedures
5
6
(C) 1999-2009, 2011 by the GRASS Development Team
7
8
This program is free software under the GNU General Public License
9
(>=v2). Read the file COPYING that comes with GRASS for details.
10
11
\author Joel Jones (CERL/UIUC), Radim Blazek
12
\author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
13
*/
14
15
#include <
grass/dbmi.h
>
16
17
/*!
18
\brief Define range based on SQL data type
19
20
\param sqltype SQL data type
21
\param[out] from
22
\param[out] to
23
*/
24
void
db_interval_range
(
int
sqltype,
int
*from,
int
*to)
25
{
26
switch
(sqltype) {
27
case
DB_SQL_TYPE_DATE
:
28
*from =
DB_YEAR
;
29
*to =
DB_DAY
;
30
return
;
31
case
DB_SQL_TYPE_TIME
:
32
*from =
DB_HOUR
;
33
*to =
DB_FRACTION
;
34
return
;
35
}
36
37
if
(sqltype &
DB_YEAR
)
38
*from =
DB_YEAR
;
39
else
if
(sqltype &
DB_MONTH
)
40
*from =
DB_MONTH
;
41
else
if
(sqltype &
DB_DAY
)
42
*from =
DB_DAY
;
43
else
if
(sqltype &
DB_HOUR
)
44
*from =
DB_HOUR
;
45
else
if
(sqltype &
DB_MINUTE
)
46
*from =
DB_MINUTE
;
47
else
if
(sqltype &
DB_SECOND
)
48
*from =
DB_SECOND
;
49
else
if
(sqltype &
DB_FRACTION
)
50
*from =
DB_FRACTION
;
51
else
52
*from = 0;
53
54
if
(sqltype & DB_FRACTION)
55
*to =
DB_FRACTION
;
56
else
if
(sqltype & DB_SECOND)
57
*to =
DB_SECOND
;
58
else
if
(sqltype & DB_MINUTE)
59
*to =
DB_MINUTE
;
60
else
if
(sqltype & DB_HOUR)
61
*to =
DB_HOUR
;
62
else
if
(sqltype & DB_DAY)
63
*to =
DB_DAY
;
64
else
if
(sqltype & DB_MONTH)
65
*to =
DB_MONTH
;
66
else
if
(sqltype & DB_YEAR)
67
*to =
DB_YEAR
;
68
else
69
*to = 0;
70
}
DB_SECOND
#define DB_SECOND
Definition:
dbmi.h:102
DB_FRACTION
#define DB_FRACTION
Definition:
dbmi.h:103
DB_HOUR
#define DB_HOUR
Definition:
dbmi.h:100
dbmi.h
DB_DAY
#define DB_DAY
Definition:
dbmi.h:99
DB_YEAR
#define DB_YEAR
Definition:
dbmi.h:97
DB_SQL_TYPE_DATE
#define DB_SQL_TYPE_DATE
Definition:
dbmi.h:88
DB_MONTH
#define DB_MONTH
Definition:
dbmi.h:98
db_interval_range
void db_interval_range(int sqltype, int *from, int *to)
Define range based on SQL data type.
Definition:
interval.c:24
DB_SQL_TYPE_TIME
#define DB_SQL_TYPE_TIME
Definition:
dbmi.h:89
DB_MINUTE
#define DB_MINUTE
Definition:
dbmi.h:101
lib
db
dbmi_base
interval.c
Generated on Tue Feb 14 2023 05:56:00 for GRASS GIS 8 Programmer's Manual by
1.8.13