~ubuntu-branches/ubuntu/trusty/drizzle/trusty-updates

« back to all changes in this revision

Viewing changes to drizzled/function/time/time.cc

  • Committer: Package Import Robot
  • Author(s): Tobias Frost
  • Date: 2012-04-04 15:12:07 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120404151207-xwsgn1xegslle4p0
Tags: 1:7.1.32-rc-1
* New upstream release.
* Plugin-filtered-replicator upstream removed and will no longer be built.
* Updating d/*install files to accommodate upstream changes from drizzle7
  to drizzle
* Added symlink in libdrizzledmessage-dev to library
* libdrizzle: soname-bump
* Rename package drizzle-plugin-performance-dictionary to shorten package name
  (due to linitan warning package-has-long-file-name)
* Debian/control: removed unused substitution variable ${shlibs:Depends} for
  -dbg and -dev packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 */