Skip to content

Commit

Permalink
use datetime.timezone.utc rather than datetime.UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
betaBison committed Aug 5, 2024
1 parent ab6038d commit 38708b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9", "3.12"]
python-version: ["3.9","3.10","3.11","3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast : false
defaults:
Expand Down
16 changes: 8 additions & 8 deletions gnss_lib_py/utils/ephemeris_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
import gzip
import ftplib
from ftplib import FTP_TLS, FTP
from datetime import datetime, timezone, timedelta, time, UTC
from datetime import datetime, timezone, timedelta, time

import unlzw3
import numpy as np
Expand Down Expand Up @@ -280,7 +280,7 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
raise RuntimeError("gnss_lib_py cannot automatically " \
+ "download rinex nav files for "\
+ "times before Jan 1, 2013")
if datetime.now(UTC).date() == date:
if datetime.now(timezone.utc).date() == date:
possible_types = ["rinex_nav_today"]
else:
if constellations is not None and list(constellations) == ["gps"]:
Expand All @@ -290,7 +290,7 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,

# download from day's stream if too early in the day
# that combined file is not yet uploaded to CDDIS.
if datetime.now(UTC) < datetime.combine(date+timedelta(days=1),
if datetime.now(timezone.utc) < datetime.combine(date+timedelta(days=1),
time(12)).astimezone(timezone.utc): # pragma: no cover
possible_types += ["rinex_nav_today"]
else:
Expand All @@ -304,9 +304,9 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
raise RuntimeError("gnss_lib_py cannot automatically " \
+ "download sp3 files for "\
+ "times before May 25, 2012")
if datetime.now(UTC).date() - timedelta(days=3) < date:
if datetime.now(timezone.utc).date() - timedelta(days=3) < date:
possible_types += ["sp3_rapid_CODE"]
elif datetime.now(UTC).date() - timedelta(days=14) < date:
elif datetime.now(timezone.utc).date() - timedelta(days=14) < date:
possible_types += ["sp3_rapid_GFZ"]
elif date >= datetime(2017, 8, 13).date():
possible_types += ["sp3_final_CODE"]
Expand All @@ -318,9 +318,9 @@ def _verify_ephemeris(file_type, gps_millis, constellations=None,
raise RuntimeError("gnss_lib_py cannot automatically " \
+ "download clk files for "\
+ "times before Oct 14, 2012")
if datetime.now(UTC).date() - timedelta(days=3) < date:
if datetime.now(timezone.utc).date() - timedelta(days=3) < date:
possible_types += ["clk_rapid_CODE"]
elif datetime.now(UTC).date() - timedelta(days=14) < date:
elif datetime.now(timezone.utc).date() - timedelta(days=14) < date:
possible_types += ["clk_rapid_GFZ"]
elif date >= datetime(2020, 7, 5).date():
possible_types += ["clk_final_CODE"]
Expand Down Expand Up @@ -430,7 +430,7 @@ def _extract_ephemeris_dates(file_type, dt_timestamps):
needed_dates.update({dt.date() + timedelta(days=1) for dt in dt_timestamps
if ((dt >= datetime.combine(dt.date(),
time(22,tzinfo=timezone.utc))) &
(dt.date() != datetime.now(UTC).date()))
(dt.date() != datetime.now(timezone.utc).date()))
})

else:
Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_ephemeris_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import os
import ftplib
from datetime import datetime, timezone, timedelta, time, UTC
from datetime import datetime, timezone, timedelta, time

import pytest
import requests
Expand Down Expand Up @@ -347,10 +347,10 @@ def test_extract_ephemeris_dates():
datetime(2023, 7, 27).date()]

# check don't add next day if after 10pm on current day
ten_pm_utc_today = datetime.combine(datetime.now(UTC).date(),
ten_pm_utc_today = datetime.combine(datetime.now(timezone.utc).date(),
time(22,tzinfo=timezone.utc))
dates = ed._extract_ephemeris_dates("rinex_nav", np.array([ten_pm_utc_today]))
assert dates == [datetime.now(UTC).date()]
assert dates == [datetime.now(timezone.utc).date()]

# check that across multiple days there aren't duplicates
dates = ed._extract_ephemeris_dates("rinex_nav", np.array([noon_utc,
Expand Down

0 comments on commit 38708b9

Please sign in to comment.