~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-18 00:22:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: osullivan.padraig@gmail.com-20090918002238-zq7mui4r2yzoidz1
Extracted KeyUse into its own header file and placed it within the
drizzled::optimizer namespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
22
22
#include "drizzled/function/time/date.h"
23
23
#include "drizzled/temporal.h"
24
24
 
25
 
namespace drizzled
26
 
{
27
 
 
28
25
String *Item_date::val_str(String *str)
29
26
{
30
27
  assert(fixed);
31
28
 
32
29
  /* We have our subclass convert a Date temporal for us */
33
 
  Date temporal;
 
30
  drizzled::Date temporal;
34
31
  if (! get_temporal(temporal))
35
32
    return (String *) NULL; /* get_temporal throws error. */
36
33
 
37
 
  if (str->alloc(type::Time::MAX_STRING_LENGTH))
 
34
  if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
38
35
  {
39
36
    null_value= true;
40
37
    return (String *) NULL;
41
38
  }
42
39
 
43
40
  /* Convert the Date to a string and return it */
44
 
  size_t new_length;
45
 
  new_length= temporal.to_string(str->c_ptr(), type::Time::MAX_STRING_LENGTH);
46
 
  assert(new_length < type::Time::MAX_STRING_LENGTH);
 
41
  int new_length;
 
42
  new_length= temporal.to_string(str->c_ptr(), MAX_DATE_STRING_REP_LENGTH);
 
43
  assert(new_length < MAX_DATE_STRING_REP_LENGTH);
47
44
  str->length(new_length);
48
45
  return str;
49
46
}
53
50
  assert(fixed);
54
51
 
55
52
  /* We have our subclass convert a Date temporal for us */
56
 
  Date temporal;
 
53
  drizzled::Date temporal;
57
54
  if (! get_temporal(temporal))
58
55
    return 0; /* get_temporal throws error. */
59
56
 
62
59
  temporal.to_int32_t(&int_value);
63
60
  return (int64_t) int_value;
64
61
}
65
 
 
66
 
} /* namespace drizzled */