Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
tukiains committed Nov 22, 2023
1 parent 978ceca commit c71ab8a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rpgpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def rpg_seconds2datetime64(
np.ndarray: A NumPy array of datetime64 timestamps in UTC.
"""
datetime_data = np.datetime64("2001-01-01") + seconds.astype("timedelta64[s]")
datetime_data = np.datetime64("2001-01-01") + np.asarray(
seconds, dtype="timedelta64[s]"
)

if milliseconds is not None:
datetime_data += milliseconds.astype("timedelta64[ms]")
datetime_data += np.asarray(milliseconds, dtype="timedelta64[ms]")

if date_only:
return np.array([dt64.astype("datetime64[D]") for dt64 in datetime_data])
return datetime_data.astype("datetime64[D]")

return datetime_data

Expand Down

0 comments on commit c71ab8a

Please sign in to comment.