Skip to content

Commit 7025b5a

Browse files
committed
core (fix): replace UTC with timezone.utc
As per #1, UTC requires python 3.11 so limits jupyter notebook kernels we can run in
1 parent 6a2fedf commit 7025b5a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "practable"
7-
version = "0.0.16"
7+
version = "0.0.17"
88
authors = [
99
{ name="Timothy Drysdale", email="timothy.d.drysdale@gmail.com" },
1010
]

src/practable/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
"""
1414
import collections.abc
15-
from datetime import datetime, timedelta, UTC
15+
from datetime import datetime, timedelta, timezone
1616
import json
1717
import math
1818
import numpy as np
@@ -86,7 +86,7 @@ def book(self, duration, selected=""):
8686
if not isinstance(duration, timedelta):
8787
raise TypeError("duration must be a datetime.timedelta")
8888

89-
start = datetime.now(UTC)
89+
start = datetime.now(timezone.utc)
9090
end = start + duration
9191

9292
if selected == "":
@@ -163,7 +163,7 @@ def check_slot_available(self, slot):
163163
start = datetime.fromisoformat(avail[0]["start"])
164164
end = datetime.fromisoformat(avail[0]["end"])
165165
when = {"start": start, "end": end}
166-
available_now = when["start"] <= (datetime.now(UTC) +
166+
available_now = when["start"] <= (datetime.now(timezone.utc) +
167167
timedelta(seconds=1))
168168

169169
return available_now, when
@@ -260,9 +260,9 @@ def get_activity(self, booking):
260260

261261
#remove stale activities
262262
activities = self.activities
263-
now = datetime.now(UTC)
263+
now = datetime.now(timezone.UTC)
264264
for activity in activities:
265-
if datetime.fromtimestamp(activity["exp"], tz=UTC) > now:
265+
if datetime.fromtimestamp(activity["exp"], tz=timezone.utc) > now:
266266
del self.activities[activity]
267267

268268
ad = r.json()
@@ -292,7 +292,7 @@ def get_bookings(self):
292292

293293
bookings = r.json()
294294

295-
now = datetime.now(UTC)
295+
now = datetime.now(timezone.utc)
296296

297297
self.bookings = []
298298

0 commit comments

Comments
 (0)