Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
21 : #define _CONNECTIVITY_FILE_FDATEFUNCTIONS_HXX_
22 :
23 : #include "file/fcode.hxx"
24 : #include "file/filedllapi.hxx"
25 :
26 : namespace connectivity
27 : {
28 : namespace file
29 : {
30 : /** DAYOFWEEK(date)
31 : Returns the weekday index for date (1 = Sunday, 2 = Monday, ... 7 = Saturday). These index values correspond to the ODBC standard.
32 :
33 : > SELECT DAYOFWEEK('1998-02-03');
34 : -> 3
35 : */
36 0 : class OOp_DayOfWeek : public OUnaryOperator
37 : {
38 : protected:
39 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
40 : };
41 :
42 : /** DAYOFMONTH(date)
43 : Returns the day of the month for date, in the range 1 to 31:
44 :
45 : > SELECT DAYOFMONTH('1998-02-03');
46 : -> 3
47 : */
48 0 : class OOp_DayOfMonth : public OUnaryOperator
49 : {
50 : protected:
51 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
52 : };
53 :
54 : /** DAYOFYEAR(date)
55 : Returns the day of the year for date, in the range 1 to 366:
56 :
57 : > SELECT DAYOFYEAR('1998-02-03');
58 : -> 34
59 :
60 : */
61 0 : class OOp_DayOfYear : public OUnaryOperator
62 : {
63 : protected:
64 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
65 : };
66 :
67 : /** MONTH(date)
68 : Returns the month for date, in the range 1 to 12:
69 :
70 : > SELECT MONTH('1998-02-03');
71 : -> 2
72 : */
73 0 : class OOp_Month : public OUnaryOperator
74 : {
75 : protected:
76 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
77 : };
78 :
79 : /** DAYNAME(date)
80 : Returns the name of the weekday for date:
81 :
82 : > SELECT DAYNAME('1998-02-05');
83 : -> 'Thursday'
84 :
85 : */
86 0 : class OOp_DayName : public OUnaryOperator
87 : {
88 : protected:
89 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
90 : };
91 :
92 : /** MONTHNAME(date)
93 : Returns the name of the month for date:
94 :
95 : > SELECT MONTHNAME('1998-02-05');
96 : -> 'February'
97 :
98 : */
99 0 : class OOp_MonthName : public OUnaryOperator
100 : {
101 : protected:
102 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
103 : };
104 :
105 : /** QUARTER(date)
106 : Returns the quarter of the year for date, in the range 1 to 4:
107 :
108 : > SELECT QUARTER('98-04-01');
109 : -> 2
110 :
111 : */
112 0 : class OOp_Quarter : public OUnaryOperator
113 : {
114 : protected:
115 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
116 : };
117 :
118 : /** WEEK(date)
119 : WEEK(date,first)
120 : With a single argument, returns the week for date, in the range 0 to 53 (yes, there may be the beginnings of a week 53), for locations where Sunday is the first day of the week. The two-argument form of WEEK() allows you to specify whether the week starts on Sunday or Monday and whether the return value should be in the range 0-53 or 1-52. Here is a table for how the second argument works:
121 : Value Meaning
122 : 0 Week starts on Sunday and return value is in range 0-53
123 : 1 Week starts on Monday and return value is in range 0-53
124 : 2 Week starts on Sunday and return value is in range 1-53
125 : 3 Week starts on Monday and return value is in range 1-53 (ISO 8601)
126 :
127 : > SELECT WEEK('1998-02-20');
128 : -> 7
129 : > SELECT WEEK('1998-02-20',0);
130 : -> 7
131 : > SELECT WEEK('1998-02-20',1);
132 : -> 8
133 : > SELECT WEEK('1998-12-31',1);
134 : -> 53
135 :
136 : */
137 0 : class OOp_Week : public ONthOperator
138 : {
139 : protected:
140 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
141 : };
142 :
143 : /** YEAR(date)
144 : Returns the year for date, in the range 1000 to 9999:
145 :
146 : > SELECT YEAR('98-02-03');
147 : -> 1998
148 : */
149 0 : class OOp_Year : public OUnaryOperator
150 : {
151 : protected:
152 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
153 : };
154 :
155 : /** HOUR(time)
156 : Returns the hour for time, in the range 0 to 23:
157 :
158 : > SELECT HOUR('10:05:03');
159 : -> 10
160 : */
161 0 : class OOp_Hour : public OUnaryOperator
162 : {
163 : protected:
164 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
165 : };
166 :
167 : /** MINUTE(time)
168 : Returns the minute for time, in the range 0 to 59:
169 :
170 : > SELECT MINUTE('98-02-03 10:05:03');
171 : -> 5
172 :
173 : */
174 0 : class OOp_Minute : public OUnaryOperator
175 : {
176 : protected:
177 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
178 : };
179 :
180 : /** SECOND(time)
181 : Returns the second for time, in the range 0 to 59:
182 :
183 : > SELECT SECOND('10:05:03');
184 : -> 3
185 : */
186 0 : class OOp_Second : public OUnaryOperator
187 : {
188 : protected:
189 : virtual ORowSetValue operate(const ORowSetValue& lhs) const;
190 : };
191 :
192 : /** CURDATE()
193 : CURRENT_DATE
194 : Returns today's date as a value in 'YYYY-MM-DD' or YYYYMMDD format, depending on whether the function is used in a string or numeric context:
195 :
196 : > SELECT CURDATE();
197 : -> '1997-12-15'
198 : */
199 0 : class OOp_CurDate : public ONthOperator
200 : {
201 : protected:
202 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
203 : };
204 :
205 : /** CURTIME()
206 : CURRENT_TIME
207 : Returns the current time as a value in 'HH:MM:SS' or HHMMSS format, depending on whether the function is used in a string or numeric context:
208 :
209 : > SELECT CURTIME();
210 : -> '23:50:26'
211 : */
212 0 : class OOp_CurTime : public ONthOperator
213 : {
214 : protected:
215 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
216 : };
217 :
218 : /** NOW()
219 : Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context:
220 :
221 : > SELECT NOW();
222 : -> '1997-12-15 23:50:26'
223 : */
224 0 : class OOp_Now : public ONthOperator
225 : {
226 : protected:
227 : virtual ORowSetValue operate(const ::std::vector<ORowSetValue>& lhs) const;
228 : };
229 : }
230 : }
231 :
232 : #endif // _CONNECTIVITY_FILE_FCODE_HXX_
233 :
234 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|