~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/datetime.cc

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <string>
32
32
 
33
33
 
 
34
namespace drizzled
 
35
{
 
36
 
34
37
/****************************************************************************
35
38
** datetime type
36
39
** In string context: YYYY-MM-DD HH:MM:DD
47
50
   * Try to create a DateTime from the supplied string.  Throw an error
48
51
   * if unable to create a valid DateTime.  
49
52
   */
50
 
  drizzled::DateTime temporal;
 
53
  DateTime temporal;
51
54
  if (! temporal.from_string(from, (size_t) len))
52
55
  {
53
56
    my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), from);
92
95
   * Try to create a DateTime from the supplied integer.  Throw an error
93
96
   * if unable to create a valid DateTime.  
94
97
   */
95
 
  drizzled::DateTime temporal;
 
98
  DateTime temporal;
96
99
  if (! temporal.from_int64_t(from))
97
100
  {
98
101
    /* Convert the integer to a string using stringstream */
125
128
 
126
129
int Field_datetime::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type)
127
130
{
128
 
  drizzled::DateTime temporal;
 
131
  DateTime temporal;
129
132
 
130
133
  temporal.set_years(ltime->year);
131
134
  temporal.set_months(ltime->month);
183
186
String *Field_datetime::val_str(String *val_buffer,
184
187
                                String *)
185
188
{
186
 
  val_buffer->alloc(drizzled::DateTime::MAX_STRING_LENGTH);
187
 
  val_buffer->length(drizzled::DateTime::MAX_STRING_LENGTH);
 
189
  val_buffer->alloc(DateTime::MAX_STRING_LENGTH);
 
190
  val_buffer->length(DateTime::MAX_STRING_LENGTH);
188
191
  int64_t tmp;
189
192
 
190
193
  ASSERT_COLUMN_MARKED_FOR_READ;
196
199
#endif
197
200
    int64_tget(tmp,ptr);
198
201
 
199
 
  drizzled::DateTime dt;
 
202
  DateTime dt;
200
203
 
201
204
  /* TODO: add an assert that this succeeds
202
205
   * currently fails due to bug in allowing
210
213
                               */
211
214
 
212
215
  int rlen;
213
 
  rlen= dt.to_string((char*)val_buffer->ptr(), drizzled::DateTime::MAX_STRING_LENGTH);
214
 
  assert((rlen+1) <  drizzled::DateTime::MAX_STRING_LENGTH);
 
216
  rlen= dt.to_string((char*)val_buffer->ptr(), DateTime::MAX_STRING_LENGTH);
 
217
  assert((rlen+1) <  DateTime::MAX_STRING_LENGTH);
215
218
 
216
219
  val_buffer->length(rlen);
217
220
 
295
298
  res.set_ascii(STRING_WITH_LEN("datetime"));
296
299
}
297
300
 
 
301
} /* namespace drizzled */