def ignore_past(execution_date: Pendulum) -> Pendulum:
    """
    Decide what execution_date the sensor should look for
    If execution date is more then 30 days ago, return execution date of 30 days ago
    otherwise return execution date
    :param execution_date:
    :return: Pendulum
    """

    execution_diff = execution_date.diff().in_days()

    if execution_diff > 30:
        return execution_date.add(days=(execution_diff - 30))

    return execution_date
Beispiel #2
0
 def test_diff_in_seconds_with_timezones(self):
     dt_ottawa = Pendulum(2000, 1, 1, 13, tzinfo='America/Toronto')
     dt_vancouver = Pendulum(2000, 1, 1, 13, tzinfo='America/Vancouver')
     self.assertEqual(3 * 60 * 60,
                      dt_ottawa.diff(dt_vancouver).in_seconds())
Beispiel #3
0
 def test_diff_in_minutes_positive_big(self):
     dt = Pendulum(2000, 1, 1)
     self.assertEqual(
         1502,
         dt.diff(dt.copy().add(hours=25).add(minutes=2)).in_minutes())
Beispiel #4
0
 def test_diff_in_seconds_with_timezones(self):
     dt_ottawa = Pendulum(2000, 1, 1, 13, tzinfo='America/Toronto')
     dt_vancouver = Pendulum(2000, 1, 1, 13, tzinfo='America/Vancouver')
     self.assertEqual(3 * 60 * 60, dt_ottawa.diff(dt_vancouver).in_seconds())