574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
1241.9.36
by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h. |
20 |
#include "config.h" |
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
21 |
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
22 |
#include "drizzled/function/time/curdate.h" |
23 |
#include "drizzled/tztime.h" |
|
24 |
#include "drizzled/temporal.h" |
|
25 |
#include "drizzled/session.h" |
|
584.1.15
by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes. |
26 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
27 |
namespace drizzled |
28 |
{
|
|
29 |
||
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
30 |
void Item_func_curdate::fix_length_and_dec() |
31 |
{
|
|
32 |
collation.set(&my_charset_bin); |
|
33 |
decimals=0; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
34 |
max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN; |
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
35 |
|
36 |
store_now_in_TIME(<ime); |
|
37 |
||
38 |
/* We don't need to set second_part and neg because they already 0 */
|
|
39 |
ltime.hour= ltime.minute= ltime.second= 0; |
|
40 |
ltime.time_type= DRIZZLE_TIMESTAMP_DATE; |
|
41 |
||
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
42 |
/**
|
43 |
* @TODO Remove ltime completely when timezones are reworked. Using this
|
|
44 |
* technique now to avoid a large patch...
|
|
45 |
*/
|
|
46 |
cached_temporal.set_years(ltime.year); |
|
47 |
cached_temporal.set_months(ltime.month); |
|
48 |
cached_temporal.set_days(ltime.day); |
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
49 |
}
|
50 |
||
51 |
/**
|
|
726.1.1
by Toru Maesaka
Use time_t instead of my_time_t which should be safe (as in wide enough) on POSIX compliant systems. |
52 |
Converts current time in time_t to DRIZZLE_TIME represenatation for local
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
53 |
time zone. Defines time zone (local) used for whole CURDATE function.
|
54 |
*/
|
|
55 |
void Item_func_curdate_local::store_now_in_TIME(DRIZZLE_TIME *now_time) |
|
56 |
{
|
|
57 |
Session *session= current_session; |
|
907.1.8
by Jay Pipes
Final removal of timezones |
58 |
time_t tmp= session->query_start(); |
59 |
||
60 |
(void) cached_temporal.from_time_t(tmp); |
|
61 |
||
62 |
now_time->year= cached_temporal.years(); |
|
63 |
now_time->month= cached_temporal.months(); |
|
64 |
now_time->day= cached_temporal.days(); |
|
65 |
now_time->hour= 0; |
|
66 |
now_time->minute= 0; |
|
67 |
now_time->second= 0; |
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
68 |
}
|
69 |
||
70 |
/**
|
|
726.1.1
by Toru Maesaka
Use time_t instead of my_time_t which should be safe (as in wide enough) on POSIX compliant systems. |
71 |
Converts current time in time_t to DRIZZLE_TIME represenatation for UTC
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
72 |
time zone. Defines time zone (UTC) used for whole UTC_DATE function.
|
73 |
*/
|
|
74 |
void Item_func_curdate_utc::store_now_in_TIME(DRIZZLE_TIME *now_time) |
|
75 |
{
|
|
907.1.8
by Jay Pipes
Final removal of timezones |
76 |
Session *session= current_session; |
77 |
time_t tmp= session->query_start(); |
|
78 |
||
79 |
(void) cached_temporal.from_time_t(tmp); |
|
80 |
||
81 |
now_time->year= cached_temporal.years(); |
|
82 |
now_time->month= cached_temporal.months(); |
|
83 |
now_time->day= cached_temporal.days(); |
|
84 |
now_time->hour= 0; |
|
85 |
now_time->minute= 0; |
|
86 |
now_time->second= 0; |
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
87 |
}
|
88 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
89 |
bool Item_func_curdate::get_temporal(Date &to) |
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
90 |
{
|
873.1.9
by Jay Pipes
This patch fixes the following functions to properly error out |
91 |
to= cached_temporal; |
92 |
return true; |
|
574.3.16
by Lee
moving functions from item_timefunc to functions/time directory |
93 |
}
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
94 |
|
95 |
} /* namespace drizzled */ |