~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-11-16 23:47:43 UTC
  • mto: (584.1.10 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116234743-c38gmv0pa2kdefaj
BrokeĀ outĀ cached_item.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
22
 
#include "drizzled/function/time/date.h"
23
 
#include "drizzled/temporal.h"
24
 
 
25
 
namespace drizzled
26
 
{
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/functions/time/date.h>
27
23
 
28
24
String *Item_date::val_str(String *str)
29
25
{
30
 
  assert(fixed);
31
 
 
32
 
  /* We have our subclass convert a Date temporal for us */
33
 
  Date temporal;
34
 
  if (! get_temporal(temporal))
35
 
    return (String *) NULL; /* get_temporal throws error. */
36
 
 
 
26
  assert(fixed == 1);
 
27
  DRIZZLE_TIME ltime;
 
28
  if (get_date(&ltime, TIME_FUZZY_DATE))
 
29
    return (String *) 0;
37
30
  if (str->alloc(MAX_DATE_STRING_REP_LENGTH))
38
31
  {
39
 
    null_value= true;
40
 
    return (String *) NULL;
 
32
    null_value= 1;
 
33
    return (String *) 0;
41
34
  }
42
 
 
43
 
  /* Convert the Date to a string and return it */
44
 
  int new_length;
45
 
  new_length= temporal.to_string(str->c_ptr(), MAX_DATE_STRING_REP_LENGTH);
46
 
  assert(new_length < MAX_DATE_STRING_REP_LENGTH);
47
 
  str->length(new_length);
 
35
  make_date((DATE_TIME_FORMAT *) 0, &ltime, str);
48
36
  return str;
49
37
}
50
38
 
 
39
 
51
40
int64_t Item_date::val_int()
52
41
{
53
 
  assert(fixed);
54
 
 
55
 
  /* We have our subclass convert a Date temporal for us */
56
 
  Date temporal;
57
 
  if (! get_temporal(temporal))
58
 
    return 0; /* get_temporal throws error. */
59
 
 
60
 
  /* Convert the Date to a string and return it */
61
 
  int32_t int_value;
62
 
  temporal.to_int32_t(&int_value);
63
 
  return (int64_t) int_value;
 
42
  assert(fixed == 1);
 
43
  DRIZZLE_TIME ltime;
 
44
  if (get_date(&ltime, TIME_FUZZY_DATE))
 
45
    return 0;
 
46
  return (int64_t) (ltime.year*10000L+ltime.month*100+ltime.day);
64
47
}
65
48
 
66
 
} /* namespace drizzled */