~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-03-05 02:06:48 UTC
  • mfrom: (907.1.8 trunk-with-temporal)
  • mto: This revision was merged to the branch mainline in revision 912.
  • Revision ID: mordred@inaugust.com-20090305020648-7jk1gie4lqsi22g8
Merged from Jay.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <drizzled/server_includes.h>
21
21
#include CSTDINT_H
22
22
#include <drizzled/function/time/from_unixtime.h>
23
 
#include <drizzled/tztime.h>
24
23
#include <drizzled/session.h>
25
24
 
 
25
#include "drizzled/temporal.h"
 
26
 
 
27
#include <sstream>
 
28
#include <string>
 
29
 
26
30
void Item_func_from_unixtime::fix_length_and_dec()
27
31
{
28
32
  session= current_session;
64
68
  return (int64_t) TIME_to_uint64_t_datetime(&time_tmp);
65
69
}
66
70
 
67
 
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime,
68
 
                                       uint32_t )
 
71
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime, uint32_t)
69
72
{
70
73
  uint64_t tmp= (uint64_t)(args[0]->val_int());
71
74
  /*
75
78
  if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
76
79
    return 1;
77
80
 
78
 
  session->variables.time_zone->gmt_sec_to_TIME(ltime, (time_t)tmp);
 
81
  drizzled::Timestamp temporal;
 
82
  if (! temporal.from_time_t((time_t) tmp))
 
83
  {
 
84
    null_value= true;
 
85
    std::stringstream ss;
 
86
    std::string tmp_string;
 
87
    ss << tmp; ss >> tmp_string;
 
88
    my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), tmp_string.c_str());
 
89
    return 0;
 
90
  }
 
91
  
 
92
  memset(ltime, 0, sizeof(*ltime));
 
93
 
 
94
  ltime->year= temporal.years();
 
95
  ltime->month= temporal.months();
 
96
  ltime->day= temporal.days();
 
97
  ltime->hour= temporal.hours();
 
98
  ltime->minute= temporal.minutes();
 
99
  ltime->second= temporal.seconds();
 
100
  ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
79
101
 
80
102
  return 0;
81
103
}
82
 
 
83