1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#include <drizzled/server_includes.h>
22
#include <drizzled/function/time/get_format.h>
24
String *Item_func_get_format::val_str(String *str)
27
const char *format_name;
28
KNOWN_DATE_TIME_FORMAT *format;
29
String *val= args[0]->val_str(str);
32
if ((null_value= args[0]->null_value))
35
val_len= val->length();
36
for (format= &known_date_time_formats[0];
37
(format_name= format->format_name);
40
uint32_t format_name_len;
41
format_name_len= strlen(format_name);
42
if (val_len == format_name_len &&
43
!my_strnncoll(&my_charset_utf8_general_ci,
44
(const unsigned char *) val->ptr(), val_len,
45
(const unsigned char *) format_name, val_len))
47
const char *format_str= get_date_time_format_str(format, type);
48
str->set(format_str, strlen(format_str), &my_charset_bin);
57
void Item_func_get_format::print(String *str, enum_query_type query_type)
59
str->append(func_name());
63
case DRIZZLE_TIMESTAMP_DATE:
64
str->append(STRING_WITH_LEN("DATE, "));
66
case DRIZZLE_TIMESTAMP_DATETIME:
67
str->append(STRING_WITH_LEN("DATETIME, "));
69
case DRIZZLE_TIMESTAMP_TIME:
70
str->append(STRING_WITH_LEN("TIME, "));
75
args[0]->print(str, query_type);