mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Fix for bug #4756 "STR_TO_DATE() returning bad results with AM/PM".
Added support of converion specifiers mentioned in manual but missing in code. mysql-test/r/date_formats.result: Added tests of str_to_date() with new %T, %r and %V, %v conversion specifiers, and also some other specifiers for which tests were missing previously. mysql-test/t/date_formats.test: Added tests of str_to_date() and new %T, %r and %V, %v conversion specifiers, and also some other specifiers for which tests were missing previously. sql/item_timefunc.cc: Added support for %T, %r, %V, %v, %X, %x conversion specifiers to extract_date_time() function. Also simplified a bit calculation of dates from week number.
This commit is contained in:
@@ -132,16 +132,23 @@ insert into t1 values
|
||||
('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
|
||||
('10:20:10', '%H:%i:%s'),
|
||||
('10:20:10', '%h:%i:%s.%f'),
|
||||
('10:20:10', '%T'),
|
||||
('10:20:10AM', '%h:%i:%s%p'),
|
||||
('10:20:10AM', '%r'),
|
||||
('10:20:10.44AM', '%h:%i:%s.%f%p'),
|
||||
('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
|
||||
('15 September 2001', '%d %M %Y'),
|
||||
('15 SEPTEMB 2001', '%d %M %Y'),
|
||||
('15 MAY 2001', '%d %b %Y'),
|
||||
('15th May 2001', '%D %b %Y'),
|
||||
('Sunday 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Sund 15 MAY 2001', '%W %d %b %Y'),
|
||||
('Tuesday 00 2002', '%W %U %Y'),
|
||||
('Thursday 53 1998', '%W %u %Y'),
|
||||
('Sunday 01 2001', '%W %v %x'),
|
||||
('Tuesday 52 2001', '%W %V %X'),
|
||||
('060 2004', '%j %Y'),
|
||||
('4 53 1998', '%w %u %Y'),
|
||||
('15-01-2001', '%d-%m-%Y %H:%i:%S'),
|
||||
('15-01-20', '%d-%m-%y'),
|
||||
('15-2001-1', '%d-%Y-%c');
|
||||
@@ -156,7 +163,7 @@ select date,format,DATE(str_to_date(date, format)) as date2 from t1;
|
||||
select date,format,TIME(str_to_date(date, format)) as time from t1;
|
||||
select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
|
||||
|
||||
# Test wrong dates
|
||||
# Test wrong dates or converion specifiers
|
||||
|
||||
truncate table t1;
|
||||
insert into t1 values
|
||||
@@ -169,10 +176,13 @@ insert into t1 values
|
||||
('15 Septembei 2001', '%d %M %Y'),
|
||||
('15 Ju 2001', '%d %M %Y'),
|
||||
('Sund 15 MA', '%W %d %b %Y'),
|
||||
('Sunday 01 2001', '%W %V %X'),
|
||||
('Thursdai 12 1998', '%W %u %Y'),
|
||||
(NULL, get_format(DATE,'USA')),
|
||||
('Tuesday 52 2001', '%W %V %X');
|
||||
('Sunday 01 2001', '%W %v %X'),
|
||||
('Tuesday 52 2001', '%W %V %x'),
|
||||
('Tuesday 52 2001', '%W %V %Y'),
|
||||
('Tuesday 52 2001', '%W %u %x'),
|
||||
('7 53 1998', '%w %u %Y'),
|
||||
(NULL, get_format(DATE,'USA'));
|
||||
select date,format,str_to_date(date, format) as str_to_date from t1;
|
||||
select date,format,concat(str_to_date(date, format),'') as con from t1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user