83
83
if (not temporal.from_string(from, (size_t) len))
85
std::string tmp(boost::lexical_cast<std::string>(from));
86
my_error(ER_INVALID_TIME_VALUE, MYF(0), tmp.c_str());
85
my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), from);
95
94
int Time::store(double from)
97
96
ASSERT_COLUMN_MARKED_FOR_WRITE;
103
if (from > (double)TIME_MAX_VALUE)
108
else if (from < (double) - TIME_MAX_VALUE)
110
tmp= -TIME_MAX_VALUE;
115
tmp=(long) floor(fabs(from)); // Remove fractions
120
if (tmp % 100 > 59 || tmp/100 % 100 > 59)
100
if (from > (double)TIME_MAX_VALUE)
103
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
104
ER_WARN_DATA_OUT_OF_RANGE, from, DRIZZLE_TIMESTAMP_TIME);
107
else if (from < (double) - TIME_MAX_VALUE)
109
tmp= -TIME_MAX_VALUE;
110
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
111
ER_WARN_DATA_OUT_OF_RANGE, from, DRIZZLE_TIMESTAMP_TIME);
116
tmp=(long) floor(fabs(from)); // Remove fractions
121
if (tmp % 100 > 59 || tmp/100 % 100 > 59)
124
set_datetime_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
125
ER_WARN_DATA_OUT_OF_RANGE, from,
126
DRIZZLE_TIMESTAMP_TIME);
126
132
return store(tmp, false);
130
std::string tmp(boost::lexical_cast<std::string>(from));
131
my_error(ER_INVALID_TIME_VALUE, MYF(0), tmp.c_str());
136
137
int Time::store(int64_t from, bool)
142
143
* if unable to create a valid DateTime.
144
145
drizzled::Time temporal;
145
if (not temporal.from_time_t(from))
146
if (! temporal.from_time_t(from))
147
148
/* Convert the integer to a string using boost::lexical_cast */
148
149
std::string tmp(boost::lexical_cast<std::string>(from));
149
my_error(ER_INVALID_TIME_VALUE, MYF(0), tmp.c_str());
151
my_error(ER_INVALID_UNIX_TIMESTAMP_VALUE, MYF(ME_FATALERROR), tmp.c_str());
218
220
return val_buffer;
221
bool Time::get_date(type::Time <ime, uint32_t)
223
bool Time::get_date(type::Time *ltime, uint32_t)
225
memset(ltime, 0, sizeof(*ltime));
225
227
drizzled::Time temporal;
226
228
unpack_time(temporal);
228
ltime.time_type= type::DRIZZLE_TIMESTAMP_DATETIME;
229
ltime.year= temporal.years();
230
ltime.month= temporal.months();
231
ltime.day= temporal.days();
232
ltime.hour= temporal.hours();
233
ltime.minute= temporal.minutes();
234
ltime.second= temporal.seconds();
230
ltime->time_type= DRIZZLE_TIMESTAMP_DATETIME;
231
ltime->year= temporal.years();
232
ltime->month= temporal.months();
233
ltime->day= temporal.days();
234
ltime->hour= temporal.hours();
235
ltime->minute= temporal.minutes();
236
ltime->second= temporal.seconds();
239
bool Time::get_time(type::Time <ime)
241
bool Time::get_time(type::Time *ltime)
241
243
return Time::get_date(ltime, 0);