Skip to content

Commit

Permalink
fix time-zone warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 29, 2025
1 parent af1191b commit e3871b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/specsscan/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,10 @@ def handle_meta(
ts_from = dt.datetime.timestamp(datetime_list[0]) # POSIX timestamp
ts_to = dt.datetime.timestamp(datetime_list[-1]) # POSIX timestamp
metadata["timing"] = {
"acquisition_start": dt.datetime.utcfromtimestamp(ts_from)
"acquisition_start": dt.datetime.fromtimestamp(ts_from, dt.timezone.utc)
.replace(tzinfo=dt.timezone.utc)
.isoformat(),
"acquisition_stop": dt.datetime.utcfromtimestamp(ts_to)
"acquisition_stop": dt.datetime.fromtimestamp(ts_to, dt.timezone.utc)
.replace(tzinfo=dt.timezone.utc)
.isoformat(),
"acquisition_duration": int(ts_to - ts_from),
Expand Down
6 changes: 3 additions & 3 deletions src/specsscan/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def fetch_epics_metadata(self, ts_from: float, ts_to: float, metadata: dict) ->
Returns:
dict: Updated metadata dictionary.
"""
start = datetime.datetime.utcfromtimestamp(ts_from)
start = datetime.datetime.fromtimestamp(ts_from, datetime.timezone.utc).isoformat()

# replace metadata names by epics channels
try:
Expand Down Expand Up @@ -315,8 +315,8 @@ def get_archiver_data(
Returns:
tuple[np.ndarray, np.ndarray]: The extracted time stamps and corresponding data
"""
iso_from = datetime.datetime.utcfromtimestamp(ts_from).isoformat()
iso_to = datetime.datetime.utcfromtimestamp(ts_to).isoformat()
iso_from = datetime.datetime.fromtimestamp(ts_from, datetime.timezone.utc).isoformat()
iso_to = datetime.datetime.fromtimestamp(ts_to, datetime.timezone.utc).isoformat()
req_str = archiver_url + archiver_channel + "&from=" + iso_from + "Z&to=" + iso_to + "Z"
with urlopen(req_str) as req:
data = json.load(req)
Expand Down

0 comments on commit e3871b3

Please sign in to comment.