31
31
/* Position for YYYY-DD-MM HH-MM-DD.FFFFFF AM in default format */
33
static uchar internal_format_positions[]=
34
{0, 1, 2, 3, 4, 5, 6, (uchar) 255};
33
static unsigned char internal_format_positions[]=
34
{0, 1, 2, 3, 4, 5, 6, (unsigned char) 255};
36
36
static char time_separator=':';
38
38
static uint32_t const days_at_timestart=719528; /* daynr at 1970.01.01 */
39
uchar days_in_month[]= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
39
unsigned char days_in_month[]= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
42
42
Offset of system time zone from UTC in seconds used to speed up
156
156
#define MAX_DATE_PARTS 8
158
158
enum enum_drizzle_timestamp_type
159
str_to_datetime(const char *str, uint length, DRIZZLE_TIME *l_time,
160
uint flags, int *was_cut)
159
str_to_datetime(const char *str, uint32_t length, DRIZZLE_TIME *l_time,
160
uint32_t flags, int *was_cut)
162
uint field_length, year_length=4, digits, i, number_of_fields;
163
uint date[MAX_DATE_PARTS], date_len[MAX_DATE_PARTS];
164
uint add_hours= 0, start_loop;
162
uint32_t field_length, year_length=4, digits, i, number_of_fields;
163
uint32_t date[MAX_DATE_PARTS], date_len[MAX_DATE_PARTS];
164
uint32_t add_hours= 0, start_loop;
165
165
uint32_t not_zero_date, allow_space;
166
166
bool is_internal_format;
167
167
const char *pos, *last_field_pos=NULL;
168
168
const char *end=str+length;
169
const uchar *format_position;
169
const unsigned char *format_position;
170
170
bool found_delimitier= 0, found_space= 0;
171
uint frac_pos, frac_len;
171
uint32_t frac_pos, frac_len;
244
244
2003-03-03 20:00:20 AM
245
245
20:00:20.000000 AM 03-03-2000
247
i= max((uint) format_position[0], (uint) format_position[1]);
247
i= cmax((uint) format_position[0], (uint) format_position[1]);
248
248
set_if_bigger(i, (uint) format_position[2]);
249
249
allow_space= ((1 << i) | (1 << format_position[6]));
250
250
allow_space&= (1 | 2 | 4 | 8);
258
258
const char *start= str;
259
uint32_t tmp_value= (uint) (uchar) (*str++ - '0');
259
uint32_t tmp_value= (uint) (unsigned char) (*str++ - '0');
260
260
while (str != end && my_isdigit(&my_charset_utf8_general_ci,str[0]) &&
261
261
(!is_internal_format || --field_length))
263
tmp_value=tmp_value*10 + (uint32_t) (uchar) (*str - '0');
263
tmp_value=tmp_value*10 + (uint32_t) (unsigned char) (*str - '0');
266
266
date_len[i]= (uint) (str - start);
470
bool str_to_time(const char *str, uint length, DRIZZLE_TIME *l_time,
470
bool str_to_time(const char *str, uint32_t length, DRIZZLE_TIME *l_time,
473
473
uint32_t date[5];
475
475
const char *end=str+length, *end_of_days;
476
476
bool found_days,found_hours;
558
558
/* Fix the date to assume that seconds was given */
559
559
if (!found_hours && !found_days)
561
bmove_upp((uchar*) (date+4), (uchar*) (date+state),
561
bmove_upp((unsigned char*) (date+4), (unsigned char*) (date+state),
562
562
sizeof(long)*(state-1));
563
563
memset(date, 0, sizeof(long)*(4-state));
571
571
if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_utf8_general_ci,str[1]))
573
573
int field_length= 5;
574
str++; value=(uint) (uchar) (*str - '0');
574
str++; value=(uint) (unsigned char) (*str - '0');
575
575
while (++str != end && my_isdigit(&my_charset_utf8_general_ci, *str))
577
577
if (field_length-- > 0)
578
value= value*10 + (uint) (uchar) (*str - '0');
578
value= value*10 + (uint) (unsigned char) (*str - '0');
580
580
if (field_length > 0)
581
581
value*= (long) log_10_int[field_length];
1004
1004
int my_time_to_str(const DRIZZLE_TIME *l_time, char *to)
1006
uint extra_hours= 0;
1006
uint32_t extra_hours= 0;
1007
1007
return sprintf(to, "%s%02u:%02u:%02u",
1008
1008
(l_time->neg ? "-" : ""),
1009
1009
extra_hours+ l_time->hour,
1091
1091
int64_t number_to_datetime(int64_t nr, DRIZZLE_TIME *time_res,
1092
uint flags, int *was_cut)
1092
uint32_t flags, int *was_cut)
1094
1094
long part1,part2;