~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

merged with up to date trunk

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
196
196
String *Item_datetime_typecast::val_str(String *str)
197
197
{
198
198
  assert(fixed == 1);
199
 
  DRIZZLE_TIME ltime;
 
199
  type::Time ltime;
200
200
 
201
201
  if (! get_arg0_date(&ltime, TIME_FUZZY_DATE))
202
202
  {
226
226
int64_t Item_datetime_typecast::val_int()
227
227
{
228
228
  assert(fixed == 1);
229
 
  DRIZZLE_TIME ltime;
 
229
  type::Time ltime;
230
230
  if (get_arg0_date(&ltime,1))
231
231
  {
232
232
    null_value= 1;
237
237
}
238
238
 
239
239
 
240
 
bool Item_date_typecast::get_date(DRIZZLE_TIME *ltime, uint32_t )
 
240
bool Item_date_typecast::get_date(type::Time *ltime, uint32_t )
241
241
{
242
242
  bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
243
243
  ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
246
246
}
247
247
 
248
248
 
249
 
bool Item_date_typecast::get_time(DRIZZLE_TIME *ltime)
 
249
bool Item_date_typecast::get_time(type::Time *ltime)
250
250
{
251
 
  memset(ltime, 0, sizeof(DRIZZLE_TIME));
 
251
  memset(ltime, 0, sizeof(type::Time));
252
252
  return args[0]->null_value;
253
253
}
254
254
 
256
256
String *Item_date_typecast::val_str(String *str)
257
257
{
258
258
  assert(fixed == 1);
259
 
  DRIZZLE_TIME ltime;
 
259
  type::Time ltime;
260
260
 
261
261
  if (!get_arg0_date(&ltime, TIME_FUZZY_DATE) &&
262
262
      !str->alloc(MAX_DATE_STRING_REP_LENGTH))
272
272
int64_t Item_date_typecast::val_int()
273
273
{
274
274
  assert(fixed == 1);
275
 
  DRIZZLE_TIME ltime;
 
275
  type::Time ltime;
276
276
  if ((null_value= args[0]->get_date(&ltime, TIME_FUZZY_DATE)))
277
277
    return 0;
278
278
  return (int64_t) (ltime.year * 10000L + ltime.month * 100 + ltime.day);