diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
commit | a2a2e32c02643a0cec111511220227703fda1cd5 (patch) | |
tree | 69cc2b631234c2a8e026b9cd4d72676c61c594df /sql/item_timefunc.cc | |
parent | Releasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff) | |
download | mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip |
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0ac75f90..2cf63c2d 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -473,15 +473,17 @@ err: Create a formatted date/time value in a string. */ -static bool make_date_time(const String *format, const MYSQL_TIME *l_time, - timestamp_type type, const MY_LOCALE *locale, - String *str) +static bool make_date_time(THD *thd, const String *format, + const MYSQL_TIME *l_time, timestamp_type type, + const MY_LOCALE *locale, String *str) { char intbuff[15]; uint hours_i; uint weekday; ulong length; const uchar *ptr, *end; + struct my_tz curr_tz; + Time_zone* curr_timezone= 0; str->length(0); @@ -694,6 +696,32 @@ static bool make_date_time(const String *format, const MYSQL_TIME *l_time, str->append_zerofill(weekday, 1); break; + case 'z': + { + if (!curr_timezone) + { + curr_timezone= thd->variables.time_zone; + curr_timezone->get_timezone_information(&curr_tz, l_time); + } + long minutes= labs(curr_tz.seconds_offset)/60, diff_hr, diff_min; + diff_hr= minutes/60; + diff_min= minutes%60; + + str->append(curr_tz.seconds_offset < 0 ? '-' : '+'); + str->append(static_cast<char>('0' + diff_hr/10)); + str->append(static_cast<char>('0' + diff_hr%10)); + str->append(static_cast<char>('0' + diff_min/10)); + str->append(static_cast<char>('0' + diff_min%10)); + break; + } + case 'Z': + if (!curr_timezone) + { + curr_timezone= thd->variables.time_zone; + curr_timezone->get_timezone_information(&curr_tz, l_time); + } + str->append(curr_tz.abbreviation, strlen(curr_tz.abbreviation)); + break; default: str->append_wc(wc); break; @@ -1822,6 +1850,7 @@ uint Item_func_date_format::format_length(const String *format) case 'X': /* Year, used with 'v, where week starts with Monday' */ size += 4; break; + case 'Z': /* time zone abbreviation */ case 'a': /* locale's abbreviated weekday name (Sun..Sat) */ case 'b': /* locale's abbreviated month name (Jan.Dec) */ size += 32; /* large for UTF8 locale data */ @@ -1860,6 +1889,9 @@ uint Item_func_date_format::format_length(const String *format) case 'f': /* microseconds */ size += 6; break; + case 'z': /* time zone offset */ + size += 5; + break; case 'w': /* day (of the week), numeric */ case '%': default: @@ -1907,7 +1939,7 @@ String *Item_func_date_format::val_str(String *str) /* Create the result string */ str->set_charset(collation.collation); - if (!make_date_time(format, &l_time, + if (!make_date_time(thd, format, &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, lc, str)) |