23 #if TIME_WITH_SYS_TIME
24 # include <sys/time.h>
28 # include <sys/time.h>
34 #include <drizzled/common_fwd.h>
38 extern uint64_t log_10_int[20];
39 extern unsigned char days_in_month[];
42 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1)
43 #define TIMESTAMP_MAX_VALUE INT32_MAX
44 #define TIMESTAMP_MIN_VALUE 1
47 #define YY_PART_YEAR 70
50 #define TIME_FUZZY_DATE 1
51 #define TIME_DATETIME_ONLY 2
54 #define TIME_NO_ZERO_IN_DATE (65536L*2*2*2*2*2*2*2)
57 #define TIME_NO_ZERO_DATE (TIME_NO_ZERO_IN_DATE*2)
58 #define TIME_INVALID_DATES (TIME_NO_ZERO_DATE*2)
60 #define DRIZZLE_TIME_WARN_TRUNCATED 1
61 #define DRIZZLE_TIME_WARN_OUT_OF_RANGE 2
64 #define TIME_MAX_HOUR 838
65 #define TIME_MAX_MINUTE 59
66 #define TIME_MAX_SECOND 59
67 #define TIME_MAX_VALUE (TIME_MAX_HOUR*10000 + TIME_MAX_MINUTE*100 + \
86 DRIZZLE_TIMESTAMP_NONE= -2, DRIZZLE_TIMESTAMP_ERROR= -1,
87 DRIZZLE_TIMESTAMP_DATE= 0, DRIZZLE_TIMESTAMP_DATETIME= 1, DRIZZLE_TIMESTAMP_TIME= 2
101 inline bool is_valid(datetime_t value)
114 Time(uint32_t year_arg,
120 usec_t second_part_arg,
121 timestamp_t type_arg) :
128 second_part(second_part_arg),
134 Time(uint32_t hour_arg,
137 usec_t second_part_arg,
145 second_part(second_part_arg),
147 time_type(DRIZZLE_TIMESTAMP_TIME)
151 uint32_t year, month, day, hour, minute, second;
154 timestamp_t time_type;
158 year= month= day= hour= minute= second= second_part= 0;
160 time_type= DRIZZLE_TIMESTAMP_DATE;
163 timestamp_t type()
const
168 void convert(
drizzled::String &str, timestamp_t arg= type::DRIZZLE_TIMESTAMP_DATETIME);
169 void convert(
char *str,
size_t &to_length, timestamp_t arg= type::DRIZZLE_TIMESTAMP_DATETIME);
170 void convert(datetime_t &datetime, timestamp_t arg= type::DRIZZLE_TIMESTAMP_DATETIME);
171 void convert(datetime_t &ret, int64_t nr, uint32_t flags);
172 void convert(datetime_t &ret, int64_t nr, uint32_t flags, type::cut_t &was_cut);
173 void convert(type::epoch_t &epoch,
long *my_timezone)
const;
175 void truncate(
const timestamp_t arg);
177 bool store(
const char *str,uint32_t length,
int &warning, type::timestamp_t arg= DRIZZLE_TIMESTAMP_TIME);
178 type::timestamp_t store(
const char *str, uint32_t length, uint32_t flags, type::cut_t &was_cut);
179 type::timestamp_t store(
const char *str, uint32_t length, uint32_t flags);
180 void store(type::epoch_t from);
181 void store(type::epoch_t from, usec_t from_fractional_seconds);
182 void store(
const tm&);
183 void store(
const timeval&);
186 static const uint32_t FRACTIONAL_DIGITS= 1000000;
187 static const size_t MAX_STRING_LENGTH= 32;
189 bool check(
bool not_zero_date, uint32_t flags, type::cut_t &was_cut)
const;
191 inline bool isValidEpoch()
const
193 if ((year < TIMESTAMP_MIN_YEAR) or (year == TIMESTAMP_MIN_YEAR && (month < 12 || day < 31)))
204 long calc_daynr(uint32_t year,uint32_t month,uint32_t day);
205 uint32_t calc_days_in_year(uint32_t year);
206 uint32_t year_2000_handling(uint32_t year);
227 INTERVAL_YEAR, INTERVAL_QUARTER, INTERVAL_MONTH, INTERVAL_WEEK, INTERVAL_DAY,
228 INTERVAL_HOUR, INTERVAL_MINUTE, INTERVAL_SECOND, INTERVAL_MICROSECOND,
229 INTERVAL_YEAR_MONTH, INTERVAL_DAY_HOUR, INTERVAL_DAY_MINUTE,
230 INTERVAL_DAY_SECOND, INTERVAL_HOUR_MINUTE, INTERVAL_HOUR_SECOND,
231 INTERVAL_MINUTE_SECOND, INTERVAL_DAY_MICROSECOND, INTERVAL_HOUR_MICROSECOND,
232 INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_LAST
bool check(bool not_zero_date, uint32_t flags, type::cut_t &was_cut) const
Check datetime value for validity according to flags.