diff --git a/src/msgraph_core/tasks/large_file_upload.py b/src/msgraph_core/tasks/large_file_upload.py index 882b2ad6..f0f170d0 100644 --- a/src/msgraph_core/tasks/large_file_upload.py +++ b/src/msgraph_core/tasks/large_file_upload.py @@ -73,11 +73,17 @@ def upload_session_expired(self, upload_session: Optional[Parsable] = None) -> b if expiry is None: raise ValueError("Expiry is None") if isinstance(expiry, str): - then = datetime.strptime(expiry, "%Y-%m-%dT%H:%M:%S") + then = datetime.fromisoformat(expiry) elif isinstance(expiry, datetime): then = expiry else: raise ValueError("Expiry is not a string or datetime") + + if then.tzinfo is not None and then.tzinfo.utcoffset(then) is not None: + then = then.astimezone(timezone.utc) + else: + then = then.replace(tzinfo=timezone.utc) + interval = now - then if not isinstance(interval, timedelta): raise ValueError("Interval is not a timedelta")