229452 {
229453 double d = left.months * right;
229454 if (std::isnan(d) || d < NumericLimits<int32_t>::Minimum() || d > NumericLimits<int32_t>::Maximum()) {
229455 return false;
229456 }
229457 result.months = LossyNumericCast<int32_t>(d);
229458
229459 d = left.days * right;
229460 if (std::isnan(d) || d < NumericLimits<int32_t>::Minimum() || d > NumericLimits<int32_t>::Maximum()) {
229461 return false;
229462 }
229463 result.days = LossyNumericCast<int32_t>(d);
229464
229465
229466
229467
229468
229469
229470
229471
229472
229473
229474
229475
229476
229477
229478
229479
229480
229481
229482
229484 month_remainder = PGTimestampRound(month_remainder);
229485 auto day_remainder = LossyNumericCast<int32_t>(month_remainder);
229486
229487 double sec_remainder = (left.days * right - result.days + month_remainder - day_remainder) * Interval::SECS_PER_DAY;
229488 sec_remainder = PGTimestampRound(sec_remainder);
229489
229490
229491
229492
229493
229494
229495 if (std::fabs(sec_remainder) >= Interval::SECS_PER_DAY) {
229496 result.days += LossyNumericCast<int32_t>(sec_remainder / Interval::SECS_PER_DAY);
229497 sec_remainder -= LossyNumericCast<int32_t>(sec_remainder / Interval::SECS_PER_DAY) * Interval::SECS_PER_DAY;
229498 }
229499
229500
229501 result.days += day_remainder;
229502 if (!TryCast::Operation<int64_t, double>(left.micros, d)) {
229503 return false;
229504 }
229505 d = std::nearbyint(d * right + sec_remainder * Interval::MICROS_PER_SEC);
229506 if (std::isnan(d) || !TryCast::Operation<double, int64_t>(d, result.micros)) {
229507 return false;
229508 }
229509
229510 return true;
229511}
static constexpr const int64_t DAYS_PER_MONTH
only used for interval comparison/ordering purposes, in which case a month counts as 30 days
Definition duckdb.hpp:5258