Skip to content

Commit 6d29da9

Browse files
author
Alejandro Casanovas
committed
To fix errors such as googleapis#257, we now default to UTC when no timezone can be found.
1 parent e77b35b commit 6d29da9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

O365/connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from requests_oauthlib import OAuth2Session
1717
from stringcase import pascalcase, camelcase, snakecase
1818
from tzlocal import get_localzone
19+
from pytz import UnknownTimeZoneError, UTC
1920

2021
from .utils import ME_RESOURCE, BaseTokenBackend, FileSystemTokenBackend, Token
2122

@@ -92,7 +93,11 @@ def __init__(self, *, protocol_url=None, api_version=None,
9293
self.default_resource = default_resource
9394
self.use_default_casing = True if casing_function is None else False
9495
self.casing_function = casing_function or camelcase
95-
self.timezone = timezone or get_localzone() # pytz timezone
96+
try:
97+
self.timezone = timezone or get_localzone() # pytz timezone
98+
except UnknownTimeZoneError as e:
99+
log.info('Timezone not provided and the local timezone could not be found. Default to UTC.')
100+
self.timezone = UTC # pytz.timezone('UTC')
96101
self.max_top_value = 500 # Max $top parameter value
97102

98103
# define any keyword that can be different in this protocol

0 commit comments

Comments
 (0)