| 142 | } |
| 143 | |
| 144 | TimestampVal TimestampFunctions::ToUtc(FunctionContext* context, |
| 145 | const TimestampVal& ts_val, const StringVal& tz_string_val) { |
| 146 | if (ts_val.is_null || tz_string_val.is_null) return TimestampVal::null(); |
| 147 | const TimestampValue& ts_value = TimestampValue::FromTimestampVal(ts_val); |
| 148 | if (!ts_value.HasDateAndTime()) return TimestampVal::null(); |
| 149 | |
| 150 | const StringValue& tz_string_value = StringValue::FromStringVal(tz_string_val); |
| 151 | const Timezone* timezone = GetTimezone(context, tz_string_value); |
| 152 | if (UNLIKELY(timezone == nullptr)) return ts_val; |
| 153 | |
| 154 | TimestampValue ts_value_ret = ts_value; |
| 155 | ts_value_ret.LocalToUtc(*timezone); |
| 156 | if (UNLIKELY(!ts_value_ret.HasDateAndTime())) { |
| 157 | const string& msg = |
| 158 | Substitute("Timestamp '$0' in timezone '$1' could not be converted to UTC", |
| 159 | ts_value.ToString(), tz_string_value.DebugString()); |
| 160 | context->AddWarning(msg.c_str()); |
| 161 | return TimestampVal::null(); |
| 162 | } |
| 163 | |
| 164 | TimestampVal ts_val_ret; |
| 165 | ts_value_ret.ToTimestampVal(&ts_val_ret); |
| 166 | return ts_val_ret; |
| 167 | } |
| 168 | |
| 169 | void TimestampFunctions::FromUtcAndToUtcClose(FunctionContext* context, |
| 170 | FunctionContext::FunctionStateScope scope) { |
nothing calls this directly
no test coverage detected