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, Inc.
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
24
#include <drizzled/plugin/client.h>
25
#include <drizzled/type/time.h>
30
bool plugin::Client::store(const type::Time *from)
32
const size_t buff_len= 40;
37
switch (from->time_type)
39
case type::DRIZZLE_TIMESTAMP_DATETIME:
40
length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d %02d:%02d:%02d",
47
if (from->second_part)
48
length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
51
case type::DRIZZLE_TIMESTAMP_DATE:
52
length= snprintf(buff, (buff_len-length), "%04d-%02d-%02d",
58
case type::DRIZZLE_TIMESTAMP_TIME:
59
day= (from->year || from->month) ? 0 : from->day;
60
length= snprintf(buff, (buff_len-length), "%s%02ld:%02d:%02d",
62
(long) day*24L+(long) from->hour,
65
if (from->second_part)
66
length+= snprintf(buff+length, (buff_len-length), ".%06d", (int)from->second_part);
69
case type::DRIZZLE_TIMESTAMP_NONE:
70
case type::DRIZZLE_TIMESTAMP_ERROR:
79
bool plugin::Client::store(const char *from)
84
return store(from, strlen(from));
88
} /* namespace drizzled */