| 1763 | /// limits defined in the cel-spec. See [`MAX_TIMESTAMP`] and [`MIN_TIMESTAMP`] for more details. |
| 1764 | #[cfg(feature = "chrono")] |
| 1765 | fn checked_op( |
| 1766 | op: TsOp, |
| 1767 | lhs: &chrono::DateTime<chrono::FixedOffset>, |
| 1768 | rhs: &chrono::Duration, |
| 1769 | ) -> ResolveResult { |
| 1770 | // Add lhs and rhs together, checking for data type overflow |
| 1771 | let result = match op { |
| 1772 | TsOp::Add => lhs.checked_add_signed(*rhs), |
| 1773 | TsOp::Sub => lhs.checked_sub_signed(*rhs), |
| 1774 | } |
| 1775 | .ok_or_else(|| ExecutionError::Overflow(op.str(), (*lhs).into(), (*rhs).into()))?; |
| 1776 | |
| 1777 | // Check for cel-spec limits |
| 1778 | if result > *MAX_TIMESTAMP || result < *MIN_TIMESTAMP { |
| 1779 | Err(ExecutionError::Overflow( |
| 1780 | op.str(), |
| 1781 | (*lhs).into(), |
| 1782 | (*rhs).into(), |
| 1783 | )) |
| 1784 | } else { |
| 1785 | Value::Timestamp(result).into() |
| 1786 | } |
| 1787 | } |
| 1788 | |
| 1789 | #[cfg(test)] |
| 1790 | mod tests { |