def get_date_range(self): """Return the date range for the ingest as a (start, end) tuple. If either value is not defined in the config file or cannot be converted to a date it will be returned as None. """ try: start_date = parse_date_from_string(self.datacube.start_date) except AttributeError: start_date = None try: end_date = parse_date_from_string(self.datacube.end_date) except AttributeError: end_date = None return (start_date, end_date)
def test_parse_date_bad_format(self): """Test of parsing date from string, bad format.""" date = cube_util.parse_date_from_string('A Long Time Ago') self.assertEqual(date, None)
def test_parse_date_format3(self): """Test of parsing date from string, format 3.""" date = cube_util.parse_date_from_string('13/03/2014') self.assertEqual(date, datetime.date(2014, 3, 13))
def test_parse_date_format2(self): """Test of parsing date from string, format 2.""" date = cube_util.parse_date_from_string('2014-03-13') self.assertEqual(date, datetime.date(2014, 3, 13))