~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include "config.h"
21
 
#include CSTDINT_H
 
21
 
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
26
#include "drizzled/temporal.h"
27
27
 
 
28
namespace drizzled
 
29
{
 
30
 
28
31
int64_t Item_func_unix_timestamp::val_int()
29
32
{
30
33
  DRIZZLE_TIME ltime;
50
53
    return 0;
51
54
  }
52
55
 
53
 
  drizzled::Timestamp temporal;
 
56
  Timestamp temporal;
54
57
 
55
58
  temporal.set_years(ltime.year);
56
59
  temporal.set_months(ltime.month);
63
66
  if (! temporal.is_valid())
64
67
  {
65
68
    null_value= true;
66
 
    char buff[drizzled::DateTime::MAX_STRING_LENGTH];
 
69
    char buff[DateTime::MAX_STRING_LENGTH];
67
70
    int buff_len;
68
 
    buff_len= temporal.to_string(buff, drizzled::DateTime::MAX_STRING_LENGTH);
69
 
    assert((buff_len+1) < drizzled::DateTime::MAX_STRING_LENGTH);
 
71
    buff_len= temporal.to_string(buff, DateTime::MAX_STRING_LENGTH);
 
72
    assert((buff_len+1) < DateTime::MAX_STRING_LENGTH);
70
73
    my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(0), buff);
71
74
    return 0;
72
75
  }
76
79
 
77
80
  return (int64_t) tmp;
78
81
}
 
82
 
 
83
} /* namespace drizzled */