Skip to content

Commit 4e04a12

Browse files
committed
fix(uploader): TypeError between offset-native and offset-aware datetimes
1 parent 2ff8f0c commit 4e04a12

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/msgraph_core/tasks/large_file_upload.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ def upload_session_expired(self, upload_session: Optional[Parsable] = None) -> b
7373
if expiry is None:
7474
raise ValueError("Expiry is None")
7575
if isinstance(expiry, str):
76-
then = datetime.strptime(expiry, "%Y-%m-%dT%H:%M:%S")
76+
then = datetime.fromisoformat(expiry)
7777
elif isinstance(expiry, datetime):
7878
then = expiry
7979
else:
8080
raise ValueError("Expiry is not a string or datetime")
81+
82+
if then.tzinfo is not None and then.tzinfo.utcoffset(then) is not None:
83+
then = then.astimezone(timezone.utc)
84+
else:
85+
then = then.replace(tzinfo=timezone.utc)
86+
8187
interval = now - then
8288
if not isinstance(interval, timedelta):
8389
raise ValueError("Interval is not a timedelta")

0 commit comments

Comments
 (0)