~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-01-07 09:27:07 UTC
  • Revision ID: brian@tangent.org-20090107092707-bn67qpdllfcyh3j9
Removing dead field translator code.

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
 
#include <boost/lexical_cast.hpp>
22
 
#include "drizzled/function/time/from_unixtime.h"
23
 
#include "drizzled/session.h"
24
 
#include "drizzled/temporal.h"
25
 
#include "drizzled/time_functions.h"
26
 
 
27
 
#include <sstream>
28
 
#include <string>
29
 
 
30
 
namespace drizzled
31
 
{
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/function/time/from_unixtime.h>
 
23
#include <drizzled/function/time/make_datetime.h>
 
24
#include <drizzled/tztime.h>
 
25
#include <drizzled/session.h>
32
26
 
33
27
void Item_func_from_unixtime::fix_length_and_dec()
34
28
{
35
29
  session= current_session;
36
30
  collation.set(&my_charset_bin);
37
31
  decimals= DATETIME_DEC;
38
 
  max_length=DateTime::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
32
  max_length=MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
39
33
  maybe_null= 1;
40
34
}
41
35
 
54
48
    return 0;
55
49
  }
56
50
 
57
 
  make_datetime(&time_tmp, str);
 
51
  make_datetime((DATE_TIME_FORMAT *) 0, &time_tmp, str);
58
52
 
59
53
  return str;
60
54
}
71
65
  return (int64_t) TIME_to_uint64_t_datetime(&time_tmp);
72
66
}
73
67
 
74
 
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime, uint32_t)
 
68
bool Item_func_from_unixtime::get_date(DRIZZLE_TIME *ltime,
 
69
                                       uint32_t fuzzy_date __attribute__((unused)))
75
70
{
76
71
  uint64_t tmp= (uint64_t)(args[0]->val_int());
77
72
  /*
81
76
  if ((null_value= (args[0]->null_value || tmp > TIMESTAMP_MAX_VALUE)))
82
77
    return 1;
83
78
 
84
 
  Timestamp temporal;
85
 
  if (! temporal.from_time_t((time_t) tmp))
86
 
  {
87
 
    null_value= true;
88
 
    std::string tmp_string(boost::lexical_cast<std::string>(tmp));
89
 
    my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), tmp_string.c_str());
90
 
    return 0;
91
 
  }
92
 
  
93
 
  memset(ltime, 0, sizeof(*ltime));
94
 
 
95
 
  ltime->year= temporal.years();
96
 
  ltime->month= temporal.months();
97
 
  ltime->day= temporal.days();
98
 
  ltime->hour= temporal.hours();
99
 
  ltime->minute= temporal.minutes();
100
 
  ltime->second= temporal.seconds();
101
 
  ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
 
79
  session->variables.time_zone->gmt_sec_to_TIME(ltime, (time_t)tmp);
102
80
 
103
81
  return 0;
104
82
}
105
83
 
106
 
} /* namespace drizzled */
 
84