Skip to content

Commit

Permalink
MNT: Remove use of utcnow() and change to naive datetimes instead. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
greglucas authored Oct 9, 2024
1 parent ca9ed15 commit f00ae91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pyproj/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ def _load_grid_geojson(target_directory: str | Path | None = None) -> dict[str,
target_directory = get_user_data_dir(True)
local_path = Path(target_directory, "files.geojson")
if not local_path.exists() or (
(datetime.utcnow() - datetime.fromtimestamp(local_path.stat().st_mtime)).days
> 0
(datetime.now() - datetime.fromtimestamp(local_path.stat().st_mtime)).days > 0
):
_download_resource_file(
file_url=f"{get_proj_endpoint()}/files.geojson",
Expand Down
2 changes: 1 addition & 1 deletion test/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def dummy_urlretrieve(url, local_path):
@patch("pyproj.sync.Path.stat")
def test__load_grid_geojson_old_file(stat_mock, tmp_path):
return_timestamp = MagicMock()
return_timestamp.st_mtime = (datetime.utcnow() - timedelta(days=2)).timestamp()
return_timestamp.st_mtime = (datetime.now() - timedelta(days=2)).timestamp()
stat_mock.return_value = return_timestamp
tmp_path.joinpath("files.geojson").touch()
grids = _load_grid_geojson(target_directory=tmp_path)
Expand Down

0 comments on commit f00ae91

Please sign in to comment.