61
60
temporal.to_int64_t(&int_value);
63
62
#ifdef WORDS_BIGENDIAN
64
if (getTable() && getTable()->isDatabaseLowByteFirst())
63
if (getTable() && getTable()->s->db_low_byte_first)
66
65
int8store(ptr, int_value);
76
75
ASSERT_COLUMN_MARKED_FOR_WRITE;
77
76
if (from < 0.0 || from > 99991231235959.0)
79
/* Convert the double to a string using boost::lexical_cast */
80
std::string tmp(boost::lexical_cast<std::string>(from));
78
/* Convert the double to a string using stringstream */
81
ss.precision(18); /* 18 places should be fine for error display of double input. */
82
ss << from; ss >> tmp;
82
84
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
96
98
if (! temporal.from_int64_t(from))
98
/* Convert the integer to a string using boost::lexical_cast */
99
std::string tmp(boost::lexical_cast<std::string>(from));
100
/* Convert the integer to a string using stringstream */
101
std::stringstream ss;
103
ss << from; ss >> tmp;
101
105
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp.c_str());
111
115
temporal.to_int64_t(&int_value);
113
117
#ifdef WORDS_BIGENDIAN
114
if (getTable() && getTable()->isDatabaseLowByteFirst())
118
if (getTable() && getTable()->s->db_low_byte_first)
116
120
int8store(ptr, int_value);
124
int Field_datetime::store_time(type::Time <ime, type::timestamp_t)
128
int Field_datetime::store_time(DRIZZLE_TIME *ltime, enum enum_drizzle_timestamp_type)
126
130
DateTime temporal;
128
temporal.set_years(ltime.year);
129
temporal.set_months(ltime.month);
130
temporal.set_days(ltime.day);
131
temporal.set_hours(ltime.hour);
132
temporal.set_minutes(ltime.minute);
133
temporal.set_seconds(ltime.second);
132
temporal.set_years(ltime->year);
133
temporal.set_months(ltime->month);
134
temporal.set_days(ltime->day);
135
temporal.set_hours(ltime->hour);
136
temporal.set_minutes(ltime->minute);
137
temporal.set_seconds(ltime->second);
135
139
if (! temporal.is_valid())
137
char tmp_string[type::Time::MAX_STRING_LENGTH];
141
char tmp_string[MAX_DATE_STRING_REP_LENGTH];
138
142
size_t tmp_string_len;
140
tmp_string_len= temporal.to_string(tmp_string, type::Time::MAX_STRING_LENGTH);
141
assert(tmp_string_len < type::Time::MAX_STRING_LENGTH);
144
tmp_string_len= temporal.to_string(tmp_string, MAX_DATE_STRING_REP_LENGTH);
145
assert(tmp_string_len < MAX_DATE_STRING_REP_LENGTH);
142
146
my_error(ER_INVALID_DATETIME_VALUE, MYF(ME_FATALERROR), tmp_string);
147
151
temporal.to_int64_t(&int_value);
149
153
#ifdef WORDS_BIGENDIAN
150
if (getTable() && getTable()->isDatabaseLowByteFirst())
154
if (getTable() && getTable()->s->db_low_byte_first)
152
156
int8store(ptr, int_value);
156
160
int64_tstore(ptr, int_value);
217
220
return val_buffer;
220
bool Field_datetime::get_date(type::Time <ime, uint32_t fuzzydate)
223
bool Field_datetime::get_date(DRIZZLE_TIME *ltime, uint32_t fuzzydate)
222
225
int64_t tmp=Field_datetime::val_int();
223
226
uint32_t part1,part2;
224
227
part1=(uint32_t) (tmp/INT64_C(1000000));
225
228
part2=(uint32_t) (tmp - (uint64_t) part1*INT64_C(1000000));
227
ltime.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
229
ltime.second_part= 0;
230
ltime.second= (int) (part2%100);
231
ltime.minute= (int) (part2/100%100);
232
ltime.hour= (int) (part2/10000);
233
ltime.day= (int) (part1%100);
234
ltime.month= (int) (part1/100%100);
235
ltime.year= (int) (part1/10000);
237
return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime.month || !ltime.day)) ? 1 : 0;
230
ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
232
ltime->second_part= 0;
233
ltime->second= (int) (part2%100);
234
ltime->minute= (int) (part2/100%100);
235
ltime->hour= (int) (part2/10000);
236
ltime->day= (int) (part1%100);
237
ltime->month= (int) (part1/100%100);
238
ltime->year= (int) (part1/10000);
239
return (!(fuzzydate & TIME_FUZZY_DATE) && (!ltime->month || !ltime->day)) ? 1 : 0;
240
bool Field_datetime::get_time(type::Time <ime)
242
bool Field_datetime::get_time(DRIZZLE_TIME *ltime)
242
244
return Field_datetime::get_date(ltime,0);