Ejemplo n.º 1
0
    def serialize(self) -> Dict[str, Any]:
        from airflow.serialization.serialized_objects import encode_relativedelta

        if isinstance(self._delta, datetime.timedelta):
            delta = self._delta.total_seconds()
        else:
            delta = encode_relativedelta(self._delta)
        return {"delta": delta}
Ejemplo n.º 2
0
    def serialize(self) -> dict[str, Any]:
        from airflow.serialization.serialized_objects import encode_relativedelta, encode_timezone

        interval: float | dict[str, Any]
        if isinstance(self._interval, datetime.timedelta):
            interval = self._interval.total_seconds()
        else:
            interval = encode_relativedelta(self._interval)
        timezone = encode_timezone(self._timezone)
        return {
            "expression": self._expression,
            "timezone": timezone,
            "interval": interval
        }