diff --git a/tests/datasets/test_utils.py b/tests/datasets/test_utils.py index a76b7ee4180..f2a8f758f7f 100644 --- a/tests/datasets/test_utils.py +++ b/tests/datasets/test_utils.py @@ -212,7 +212,7 @@ def test_invalid_t(self) -> None: @pytest.mark.parametrize( "date_string,format,min_datetime,max_datetime", [ - ("", "", datetime(1970, 1, 1).timestamp(), datetime.max.timestamp()), + ("", "", 0, datetime.max.timestamp()), ( "2021", "%Y", diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py index 0e33589e0c6..32295045a83 100644 --- a/torchgeo/datasets/geo.py +++ b/torchgeo/datasets/geo.py @@ -225,7 +225,7 @@ def __init__( # Skip files that rasterio is unable to read continue else: - mint = datetime(1970, 1, 1).timestamp() + mint = 0.0 maxt = datetime.max.timestamp() if "date" in match.groupdict(): date = match.group("date") @@ -449,7 +449,7 @@ def __init__( # Skip files that fiona is unable to read continue else: - mint = datetime(1970, 1, 1).timestamp() + mint = 0 maxt = datetime.max.timestamp() coords = (minx, maxx, miny, maxy, mint, maxt) self.index.insert(i, coords, filepath) diff --git a/torchgeo/datasets/utils.py b/torchgeo/datasets/utils.py index 17c41a56658..a59ef9b8f78 100644 --- a/torchgeo/datasets/utils.py +++ b/torchgeo/datasets/utils.py @@ -279,8 +279,7 @@ def disambiguate_timestamp(date_str: str, format: str) -> Tuple[float, float]: if not any([f"%{c}" in format for c in "yYcxG"]): # No temporal info - mint = datetime(1970, 1, 1) - maxt = datetime.max + return 0, datetime.max.timestamp() elif not any([f"%{c}" in format for c in "bBmjUWcxV"]): # Year resolution maxt = datetime(mint.year, 12, 31, 23, 59, 59, 999999)