diff options
author | jani@ua141d10.elisa.omakaista.fi <> | 2006-05-04 19:31:10 +0300 |
---|---|---|
committer | jani@ua141d10.elisa.omakaista.fi <> | 2006-05-04 19:31:10 +0300 |
commit | 526e1a70e2dd6b53f879cb6bad18698b76ca38bd (patch) | |
tree | 046b31757f6d6f6d3dd1147f95989bc7b9733343 | |
parent | d3467c0b4c0e6ea4a7d7f996174bc85c832af911 (diff) | |
download | mariadb-git-526e1a70e2dd6b53f879cb6bad18698b76ca38bd.tar.gz |
Fix for Bug#11326.
-rw-r--r-- | mysql-test/r/date_formats.result | 18 | ||||
-rw-r--r-- | mysql-test/t/date_formats.test | 11 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 3 |
3 files changed, 31 insertions, 1 deletions
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 014eeed27e7..edfe17b0cb4 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -473,3 +473,21 @@ NULL select str_to_date( 1, IF(1=1,NULL,NULL) ); str_to_date( 1, IF(1=1,NULL,NULL) ) NULL +SELECT TIME_FORMAT("24:00:00", '%r'); +TIME_FORMAT("24:00:00", '%r') +12:00:00 AM +SELECT TIME_FORMAT("00:00:00", '%r'); +TIME_FORMAT("00:00:00", '%r') +12:00:00 AM +SELECT TIME_FORMAT("12:00:00", '%r'); +TIME_FORMAT("12:00:00", '%r') +12:00:00 PM +SELECT TIME_FORMAT("15:00:00", '%r'); +TIME_FORMAT("15:00:00", '%r') +03:00:00 PM +SELECT TIME_FORMAT("01:00:00", '%r'); +TIME_FORMAT("01:00:00", '%r') +01:00:00 AM +SELECT TIME_FORMAT("25:00:00", '%r'); +TIME_FORMAT("25:00:00", '%r') +01:00:00 AM diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 78b4482a94a..143cddbc4fe 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -276,3 +276,14 @@ select str_to_date( 1, NULL ); select str_to_date( NULL, 1 ); select str_to_date( 1, IF(1=1,NULL,NULL) ); # End of 4.1 tests + +# +# Bug#11326 +# + +SELECT TIME_FORMAT("24:00:00", '%r'); +SELECT TIME_FORMAT("00:00:00", '%r'); +SELECT TIME_FORMAT("12:00:00", '%r'); +SELECT TIME_FORMAT("15:00:00", '%r'); +SELECT TIME_FORMAT("01:00:00", '%r'); +SELECT TIME_FORMAT("25:00:00", '%r'); diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index f3d6858755c..f26b5aae37a 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -620,7 +620,8 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, case 'r': length= my_sprintf(intbuff, (intbuff, - (l_time->hour < 12) ? "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", + ((l_time->hour % 24) < 12) ? + "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM", (l_time->hour+11)%12+1, l_time->minute, l_time->second)); |