diff options
author | Gerhard Weis <g.weis@uq.edu.au> | 2021-12-13 08:06:56 +1000 |
---|---|---|
committer | Gerhard Weis <g.weis@uq.edu.au> | 2021-12-13 08:06:56 +1000 |
commit | 07d1602048083415bc22dc72cff152c9c2e0e021 (patch) | |
tree | 6fc5875daf4002f4e8dd4b672da47083aad82b0c /src/isodate/tzinfo.py | |
parent | 4f36d7e6f6adee4c1ec719bb9beb035df4a7d76c (diff) | |
download | isodate-07d1602048083415bc22dc72cff152c9c2e0e021.tar.gz |
white space
Diffstat (limited to 'src/isodate/tzinfo.py')
-rw-r--r-- | src/isodate/tzinfo.py | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/src/isodate/tzinfo.py b/src/isodate/tzinfo.py index 5d3a42d..102b6e3 100644 --- a/src/isodate/tzinfo.py +++ b/src/isodate/tzinfo.py @@ -1,8 +1,8 @@ -''' +""" This module provides some datetime.tzinfo implementations. All those classes are taken from the Python documentation. -''' +""" from datetime import timedelta, tzinfo import time @@ -11,35 +11,35 @@ ZERO = timedelta(0) class Utc(tzinfo): - '''UTC + """UTC Universal time coordinated time zone. - ''' + """ def utcoffset(self, dt): - ''' + """ Return offset from UTC in minutes east of UTC, which is ZERO for UTC. - ''' + """ return ZERO def tzname(self, dt): - ''' + """ Return the time zone name corresponding to the datetime object dt, as a string. - ''' + """ return "UTC" def dst(self, dt): - ''' + """ Return the daylight saving time (DST) adjustment, in minutes east of UTC. - ''' + """ return ZERO def __reduce__(self): - ''' + """ When unpickling a Utc object, return the default instance below, UTC. - ''' + """ return _Utc, () @@ -48,53 +48,53 @@ UTC = Utc() def _Utc(): - ''' + """ Helper function for unpickling a Utc object. - ''' + """ return UTC class FixedOffset(tzinfo): - ''' + """ A class building tzinfo objects for fixed-offset time zones. Note that FixedOffset(0, 0, "UTC") or FixedOffset() is a different way to build a UTC tzinfo object. - ''' + """ def __init__(self, offset_hours=0, offset_minutes=0, name="UTC"): - ''' + """ Initialise an instance with time offset and name. The time offset should be positive for time zones east of UTC and negate for time zones west of UTC. - ''' + """ self.__offset = timedelta(hours=offset_hours, minutes=offset_minutes) self.__name = name def utcoffset(self, dt): - ''' + """ Return offset from UTC in minutes of UTC. - ''' + """ return self.__offset def tzname(self, dt): - ''' + """ Return the time zone name corresponding to the datetime object dt, as a string. - ''' + """ return self.__name def dst(self, dt): - ''' + """ Return the daylight saving time (DST) adjustment, in minutes east of UTC. - ''' + """ return ZERO def __repr__(self): - ''' + """ Return nicely formatted repr string. - ''' + """ return "<FixedOffset %r>" % self.__name @@ -117,37 +117,45 @@ class LocalTimezone(tzinfo): """ def utcoffset(self, dt): - ''' + """ Return offset from UTC in minutes of UTC. - ''' + """ if self._isdst(dt): return DSTOFFSET else: return STDOFFSET def dst(self, dt): - ''' + """ Return daylight saving offset. - ''' + """ if self._isdst(dt): return DSTDIFF else: return ZERO def tzname(self, dt): - ''' + """ Return the time zone name corresponding to the datetime object dt, as a string. - ''' + """ return time.tzname[self._isdst(dt)] def _isdst(self, dt): - ''' + """ Returns true if DST is active for given datetime object dt. - ''' - tt = (dt.year, dt.month, dt.day, - dt.hour, dt.minute, dt.second, - dt.weekday(), 0, -1) + """ + tt = ( + dt.year, + dt.month, + dt.day, + dt.hour, + dt.minute, + dt.second, + dt.weekday(), + 0, + -1, + ) stamp = time.mktime(tt) tt = time.localtime(stamp) return tt.tm_isdst > 0 |