~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-03-01 03:29:52 UTC
  • mfrom: (907.1.6 trunk-with-temporal)
  • Revision ID: brian@tangent.org-20090301032952-y210opnqxsfyhcla
Merge Jay's temporal

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include CSTDINT_H
22
22
#include <drizzled/function/time/date_add_interval.h>
23
23
#include <drizzled/function/time/get_interval_value.h>
24
 
#include <drizzled/function/time/make_datetime.h>
25
24
 
26
25
/*
27
26
   'interval_names' reflects the order of the enumeration interval_type.
92
91
  return 0;
93
92
}
94
93
 
95
 
 
96
94
String *Item_date_add_interval::val_str(String *str)
97
95
{
98
96
  assert(fixed == 1);
99
97
  DRIZZLE_TIME ltime;
100
 
  enum date_time_format_types format;
101
98
 
102
99
  if (Item_date_add_interval::get_date(&ltime, TIME_NO_ZERO_DATE))
103
100
    return 0;
104
101
 
105
102
  if (ltime.time_type == DRIZZLE_TIMESTAMP_DATE)
106
 
    format= DATE_ONLY;
 
103
    make_date(&ltime, str);
107
104
  else if (ltime.second_part)
108
 
    format= DATE_TIME_MICROSECOND;
 
105
  {
 
106
    /* Ensure we've got enough room for our timestamp string. */
 
107
    str->length(MAX_DATETIME_FULL_WIDTH);
 
108
    size_t length= sprintf(str->c_ptr(), "%04u-%02u-%02u %02u:%02u:%02u.%06u",
 
109
                          ltime.year,
 
110
                          ltime.month,
 
111
                          ltime.day,
 
112
                          ltime.hour,
 
113
                          ltime.minute,
 
114
                          ltime.second,
 
115
                          (uint32_t) ltime.second_part);
 
116
    str->length(length);
 
117
    str->set_charset(&my_charset_bin);
 
118
  }
109
119
  else
110
 
    format= DATE_TIME;
111
 
 
112
 
  if (!make_datetime(format, &ltime, str))
113
 
    return str;
114
 
 
115
 
  null_value=1;
116
 
  return 0;
 
120
    make_datetime(&ltime, str);
 
121
 
 
122
  return str;
117
123
}
118
124
 
119
 
 
120
125
int64_t Item_date_add_interval::val_int()
121
126
{
122
127
  assert(fixed == 1);