From 328625390ea25b4399e0c0dd7f80d1334fe4cd02 Mon Sep 17 00:00:00 2001 From: ctshim <78332782+ctshim@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:22:11 +0900 Subject: [PATCH] [CBRD-25236] Output error related to TZM in timezone information (#5002) http://jira.cubrid.org/browse/CBRD-25236 * When obtaining TZM information from the to_char() and time_format() functions, it appears differently from the date_format() function. --- src/query/string_opfunc.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/query/string_opfunc.c b/src/query/string_opfunc.c index e2b2828a4b8..da20b3ee2e7 100644 --- a/src/query/string_opfunc.c +++ b/src/query/string_opfunc.c @@ -12492,9 +12492,9 @@ db_time_format (const DB_VALUE * src_value, const DB_VALUE * format, const DB_VA strcat (res, tzd); break; case 'H': - if (tzh >= 0) + if ((tzh >= 0) && (tzm >= 0)) { - sprintf (hours_or_minutes, "%02d", tzh); + sprintf (hours_or_minutes, "%c%02d", '+', tzh); } else { @@ -12503,14 +12503,7 @@ db_time_format (const DB_VALUE * src_value, const DB_VALUE * format, const DB_VA strcat (res, hours_or_minutes); break; case 'M': - if (tzm >= 0) - { - sprintf (hours_or_minutes, "%02d", tzm); - } - else - { - sprintf (hours_or_minutes, "%c%02d", '-', -tzm); - } + sprintf (hours_or_minutes, "%02d", (tzm >= 0) ? tzm : -tzm); strcat (res, hours_or_minutes); break; } @@ -17847,18 +17840,13 @@ date_to_char (const DB_VALUE * src_value, const DB_VALUE * format_str, const DB_ } else { - tzh = -tzh; - sprintf (&result_buf[i], "%c%02d\n", '-', tzh); + sprintf (&result_buf[i], "%c%02d\n", '-', -tzh); } i += 3; break; case DT_TZM: - if (tzm < 0) - { - tzm = -tzm; - } - sprintf (&result_buf[i], "%02d\n", tzm); + sprintf (&result_buf[i], "%02d\n", ((tzm < 0) ? -tzm : tzm)); result_size--; i += 2; break;