1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-17792 New class Timestamp and cleanups in Date, Datetime, Field for rounding

This commit is contained in:
Alexander Barkov
2018-11-22 14:53:25 +04:00
parent 2ebb110c36
commit 740ce108a5
9 changed files with 184 additions and 76 deletions

View File

@ -571,6 +571,21 @@ Time::Time(int *warn, const MYSQL_TIME *from, long curdays)
}
Time::Time(int *warn, bool neg, ulonglong hour, uint minute, const Sec6 &second)
{
DBUG_ASSERT(second.sec() <= 59);
*warn= 0;
set_zero_time(this, MYSQL_TIMESTAMP_TIME);
MYSQL_TIME::neg= neg;
MYSQL_TIME::hour= hour > TIME_MAX_HOUR ? (uint) (TIME_MAX_HOUR + 1) :
(uint) hour;
MYSQL_TIME::minute= minute;
MYSQL_TIME::second= (uint) second.sec();
MYSQL_TIME::second_part= second.usec();
adjust_time_range_or_invalidate(warn);
}
void Temporal_with_date::make_from_item(THD *thd, Item *item, date_mode_t flags)
{
flags&= ~TIME_TIME_ONLY;
@ -642,6 +657,15 @@ void Datetime::make_from_datetime(THD *thd, int *warn, const MYSQL_TIME *from,
}
Datetime::Datetime(THD *thd, const timeval &tv)
{
thd->variables.time_zone->gmt_sec_to_TIME(this, tv.tv_sec);
second_part= tv.tv_usec;
thd->time_zone_used= 1;
DBUG_ASSERT(is_valid_value_slow());
}
Datetime::Datetime(THD *thd, int *warn, const MYSQL_TIME *from,
date_mode_t flags)
{