1 | /* |
2 | * This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
5 | * |
6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
7 | */ |
8 | |
9 | #ifndef _SQL_DATETIME_H_ |
10 | #define _SQL_DATETIME_H_ |
11 | |
12 | #include "sql_mvc.h" |
13 | #include "sql_symbol.h" |
14 | |
15 | typedef enum inttype { |
16 | iyear = 1, |
17 | imonth, |
18 | iday, |
19 | ihour, |
20 | imin, |
21 | isec, |
22 | iquarter, |
23 | iweek, |
24 | idow, |
25 | idoy, |
26 | icentury, |
27 | idecade |
28 | } itype; |
29 | |
30 | int parse_interval_qualifier(mvc *sql, struct dlist *pers, int *sk, int *ek, int *sp, int *ep); |
31 | /* returns 0 for month intervals, |
32 | * 1 for sec intervals, |
33 | * in both cases sk/ek contain the start and end qualifiers |
34 | * <0 for errors */ |
35 | |
36 | lng qualifier2multiplier( int sk ); |
37 | /* returns the multiplier for the given interval qualifier */ |
38 | |
39 | int parse_interval(mvc *sql, lng sign, char *str, int sk, int ek, int sp, int ep, lng *i); |
40 | /* returns 0 for month intervals and value in val, |
41 | * 1 for sec intervals and value in val, |
42 | * <0 for errors */ |
43 | |
44 | int interval_from_str(char *str, int d, int p, lng *val); |
45 | /* returns 0 for month intervals and value in val, |
46 | * 1 for sec intervals and value in val, |
47 | * <0 for errors */ |
48 | |
49 | char *datetime_field(itype field); |
50 | /* returns the datetime_field string representation */ |
51 | |
52 | int inttype2digits( int sk, int ek ); |
53 | int digits2sk( int digits); |
54 | int digits2ek( int digits ); |
55 | |
56 | #endif /*_SQL_DATETIME_H_*/ |
57 | |
58 | |