コード例 #1
0
ファイル: test_utils.py プロジェクト: matburnham/ogn-python
 def test_get_days(self):
     start = date(2018, 2, 27)
     end = date(2018, 3, 2)
     days = get_days(start, end)
     self.assertEqual(days, [
         date(2018, 2, 27),
         date(2018, 2, 28),
         date(2018, 3, 1),
         date(2018, 3, 2)
     ])
コード例 #2
0
def get_database_days(start, end):
    """Returns the first and the last day in aircraft_beacons table."""

    if start is None and end is None:
        days_from_db = db.session.query(func.min(AircraftBeacon.timestamp).label("first_day"), func.max(AircraftBeacon.timestamp).label("last_day")).one()
        start = days_from_db[0].date()
        end = days_from_db[1].date()
    else:
        start = datetime.strptime(start, "%Y-%m-%d").date()
        end = datetime.strptime(end, "%Y-%m-%d").date()

    days = get_days(start, end)

    return days