Skip to content

Commit

Permalink
update refernce for utc
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Gee committed Sep 3, 2020
1 parent 3fe4df4 commit a0965f0
Showing 1 changed file with 3 additions and 27 deletions.
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

0 comments on commit a0965f0

Please sign in to comment.