~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

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
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
22
22
#include <drizzled/function/time/unix_timestamp.h>
23
23
#include <drizzled/field/timestamp.h>
24
24
#include <drizzled/session.h>
25
25
 
26
 
#include "drizzled/temporal.h"
27
 
 
28
 
namespace drizzled
29
 
{
30
 
 
31
26
int64_t Item_func_unix_timestamp::val_int()
32
27
{
33
28
  DRIZZLE_TIME ltime;
 
29
  bool not_used;
34
30
 
35
31
  assert(fixed == 1);
36
32
  if (arg_count == 0)
53
49
    return 0;
54
50
  }
55
51
 
56
 
  Timestamp temporal;
57
 
 
58
 
  temporal.set_years(ltime.year);
59
 
  temporal.set_months(ltime.month);
60
 
  temporal.set_days(ltime.day);
61
 
  temporal.set_hours(ltime.hour);
62
 
  temporal.set_minutes(ltime.minute);
63
 
  temporal.set_seconds(ltime.second);
64
 
  temporal.set_epoch_seconds();
65
 
 
66
 
  if (! temporal.is_valid())
67
 
  {
68
 
    null_value= true;
69
 
    char buff[DateTime::MAX_STRING_LENGTH];
70
 
    int buff_len;
71
 
    buff_len= temporal.to_string(buff, DateTime::MAX_STRING_LENGTH);
72
 
    assert((buff_len+1) < DateTime::MAX_STRING_LENGTH);
73
 
    my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), buff);
74
 
    return 0;
75
 
  }
76
 
 
77
 
  time_t tmp;
78
 
  temporal.to_time_t(&tmp);
79
 
 
80
 
  return (int64_t) tmp;
 
52
  return (int64_t) TIME_to_timestamp(current_session, &ltime, &not_used);
81
53
}
82
54
 
83
 
} /* namespace drizzled */