| 636 | |
| 637 | template <typename T> |
| 638 | TimestampVal DecimalOperators::ConvertToTimestampVal( |
| 639 | const T& decimal_value, int scale, bool round, const Timezone* local_tz) { |
| 640 | typename T::StorageType seconds = decimal_value.whole_part(scale); |
| 641 | if (seconds < numeric_limits<int64_t>::min() || |
| 642 | seconds > numeric_limits<int64_t>::max()) { |
| 643 | // TimeStampVal() takes int64_t. |
| 644 | return TimestampVal::null(); |
| 645 | } |
| 646 | int32_t nanoseconds = |
| 647 | ConvertToNanoseconds(decimal_value.fractional_part(scale), scale, round); |
| 648 | if (decimal_value.is_negative()) nanoseconds *= -1; |
| 649 | TimestampVal result; |
| 650 | TimestampValue::FromUnixTimeNanos( |
| 651 | seconds, nanoseconds, local_tz).ToTimestampVal(&result); |
| 652 | return result; |
| 653 | } |
| 654 | |
| 655 | |
| 656 | TimestampVal DecimalOperators::CastToTimestampVal( |
nothing calls this directly
no test coverage detected