drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
function/time/time.cc
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
*
4
* Copyright (C) 2011 Matthew Rheaume
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 hopethat 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/time.h>
23
#include <
drizzled/temporal.h
>
24
25
namespace
drizzled
26
{
27
28
String
*
Item_time::val_str
(
String
*str)
29
{
30
assert(
fixed
);
31
32
Time
temporal;
33
if
(!get_temporal(temporal))
34
return
(
String
*)NULL;
35
36
str->alloc(type::Time::MAX_STRING_LENGTH);
37
38
size_t
new_length;
39
new_length = temporal.
to_string
(str->c_ptr(), type::Time::MAX_STRING_LENGTH);
40
assert(new_length < type::Time::MAX_STRING_LENGTH);
41
str->length(new_length);
42
return
str;
43
}
44
45
int64_t
Item_time::val_int
()
46
{
47
assert(
fixed
);
48
Time
temporal;
49
if
(!get_temporal(temporal))
50
return
0;
51
52
int32_t int_value;
53
temporal.
to_int32_t
(&int_value);
54
return
(int64_t) int_value;
55
}
56
57
}
/* namespace drizzled */
drizzled::Item_time::val_str
String * val_str(String *str)
Definition
function/time/time.cc:28
drizzled::Item_time::val_int
int64_t val_int()
Definition
function/time/time.cc:45
drizzled::Item::fixed
bool fixed
Definition
item.h:122
drizzled::String
Definition
sql_string.h:58
drizzled::Time
Definition
temporal.h:439
drizzled::Time::to_int32_t
void to_int32_t(int32_t *to) const
Definition
temporal.cc:1024
drizzled::Time::to_string
int to_string(char *to, size_t to_len) const
Definition
temporal.cc:951
drizzled
TODO: Rename this file - func.h is stupid.
Definition
abort_exception.h:27
temporal.h
← Back to Drizzle docs
drizzled
function
time
time.cc
Generated by
1.15.0