Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace UTC_Now() workaround with MSRest.UTC #13498

Merged
merged 4 commits into from
Sep 11, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update refernce for utc
  • Loading branch information
Andy Gee committed Sep 3, 2020
commit a0965f0a43c545426de345b446b0f1ee8e76b441
30 changes: 3 additions & 27 deletions sdk/servicebus/azure-servicebus/azure/servicebus/_common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import functools
import platform
from typing import Optional, Dict
from msrest.serialization import UTC as utc
from msrest.serialization import UTC


try:
Expand All @@ -33,36 +33,12 @@
_log = logging.getLogger(__name__)


class UTC(datetime.tzinfo):
"""Time Zone info for handling UTC"""

def utcoffset(self, dt):
"""UTF offset for UTC is 0."""
return datetime.timedelta(0)

def tzname(self, dt):
"""Timestamp representation."""
return "Z"

def dst(self, dt):
"""No daylight saving for UTC."""
return datetime.timedelta(hours=1)


try:
from datetime import timezone # pylint: disable=ungrouped-imports

TZ_UTC = timezone.utc # type: ignore
except ImportError:
TZ_UTC = UTC() # type: ignore


def utc_from_timestamp(timestamp):
return datetime.datetime.fromtimestamp(timestamp, tz=TZ_UTC)
return datetime.datetime.fromtimestamp(timestamp, tz=UTC())


def utc_now():
return datetime.datetime.now(utc())
return datetime.datetime.now(UTC())


def parse_conn_str(conn_str):
Expand Down