drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
curdate.cc
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, Inc.
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
20#include <config.h>
21
22#include <drizzled/function/time/curdate.h>
23#include <drizzled/temporal.h>
24#include <drizzled/session.h>
25#include <drizzled/session/times.h>
26#include <drizzled/current_session.h>
27
28namespace drizzled
29{
30
32{
33 collation.set(&my_charset_bin);
34 decimals=0;
35 max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
36
37 store_now_in_TIME(&ltime);
38
39 /* We don't need to set second_part and neg because they already 0 */
40 ltime.hour= ltime.minute= ltime.second= 0;
41 ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
42
47 cached_temporal.set_years(ltime.year);
48 cached_temporal.set_months(ltime.month);
49 cached_temporal.set_days(ltime.day);
50}
51
57{
58 (void) cached_temporal.from_time_t(current_session->times.getCurrentTimestampEpoch());
59
60 now_time->year= cached_temporal.years();
61 now_time->month= cached_temporal.months();
62 now_time->day= cached_temporal.days();
63 now_time->hour= 0;
64 now_time->minute= 0;
65 now_time->second= 0;
66 now_time->second_part= 0;
67}
68
74{
75 (void) cached_temporal.from_time_t(current_session->times.getCurrentTimestampEpoch());
76
77 now_time->year= cached_temporal.years();
78 now_time->month= cached_temporal.months();
79 now_time->day= cached_temporal.days();
80 now_time->hour= 0;
81 now_time->minute= 0;
82 now_time->second= 0;
83 now_time->second_part= 0;
84}
85
87{
88 to= cached_temporal;
89 return true;
90}
91
92} /* namespace drizzled */
static const int MAX_STRING_LENGTH
Definition temporal.h:310
void store_now_in_TIME(type::Time *now_time)
Definition curdate.cc:56
void store_now_in_TIME(type::Time *now_time)
Definition curdate.cc:73
bool get_temporal(Date &temporal)
Definition curdate.cc:86
TODO: Rename this file - func.h is stupid.