Python time.altzone() Examples
The following are 30 code examples for showing how to use time.altzone(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
time
, or try the search function
.
Example 1
Project: password_pwncheck Author: CboeSecurity File: password-pwncheck.py License: MIT License | 6 votes |
def logmsg(request,type,message,args): is_dst = time.daylight and time.localtime().tm_isdst > 0 tz = - (time.altzone if is_dst else time.timezone) / 36 if tz>=0: tz="+%04d"%tz else: tz="%05d"%tz datestr = '%d/%b/%Y %H:%M:%S' user = getattr(logStore,'user','') isValid = getattr(logStore,'isValid','') code = getattr(logStore,'code','') args = getLogDateTime(args) log = '%s %s,%s,%s,%s,%s,%s' % (datetime.now().strftime(datestr),tz,request.address_string(),user,isValid,code, message % args) with logLock: with open(cfg.logpath,'a') as fw: fw.write(log+os.linesep) return log
Example 2
Project: calibre-web Author: janeczku File: admin.py License: GNU General Public License v3.0 | 6 votes |
def admin(): version = updater_thread.get_current_version_info() if version is False: commit = _(u'Unknown') else: if 'datetime' in version: commit = version['datetime'] tz = timedelta(seconds=time.timezone if (time.localtime().tm_isdst == 0) else time.altzone) form_date = datetime.strptime(commit[:19], "%Y-%m-%dT%H:%M:%S") if len(commit) > 19: # check if string has timezone if commit[19] == '+': form_date -= timedelta(hours=int(commit[20:22]), minutes=int(commit[23:])) elif commit[19] == '-': form_date += timedelta(hours=int(commit[20:22]), minutes=int(commit[23:])) commit = format_datetime(form_date - tz, format='short', locale=get_locale()) else: commit = version['version'] allUser = ub.session.query(ub.User).all() email_settings = config.get_mail_settings() return render_title_template("admin.html", allUser=allUser, email=email_settings, config=config, commit=commit, title=_(u"Admin page"), page="admin")
Example 3
Project: mishkal Author: linuxscout File: translogger.py License: GNU General Public License v3.0 | 6 votes |
def write_log(self, environ, method, req_uri, start, status, bytes): if bytes is None: bytes = '-' if time.daylight: offset = time.altzone / 60 / 60 * -100 else: offset = time.timezone / 60 / 60 * -100 if offset >= 0: offset = "+%0.4d" % (offset) elif offset < 0: offset = "%0.4d" % (offset) d = { 'REMOTE_ADDR': environ.get('REMOTE_ADDR') or '-', 'REMOTE_USER': environ.get('REMOTE_USER') or '-', 'REQUEST_METHOD': method, 'REQUEST_URI': req_uri, 'HTTP_VERSION': environ.get('SERVER_PROTOCOL'), 'time': time.strftime('%d/%b/%Y:%H:%M:%S ', start) + offset, 'status': status.split(None, 1)[0], 'bytes': bytes, 'HTTP_REFERER': environ.get('HTTP_REFERER', '-'), 'HTTP_USER_AGENT': environ.get('HTTP_USER_AGENT', '-'), } message = self.format % d self.logger.log(self.logging_level, message)
Example 4
Project: sndlatr Author: Schibum File: imaplib2.py License: Apache License 2.0 | 6 votes |
def Time2Internaldate(date_time): """'"DD-Mmm-YYYY HH:MM:SS +HHMM"' = Time2Internaldate(date_time) Convert 'date_time' to IMAP4 INTERNALDATE representation.""" if isinstance(date_time, (int, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return ('"%2d-%s-%04d %02d:%02d:%02d %+03d%02d"' % ((tt[2], MonthNames[tt[1]], tt[0]) + tt[3:6] + divmod(zone//60, 60)))
Example 5
Project: Computable Author: ktraunmueller File: imaplib.py License: MIT License | 6 votes |
def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ if isinstance(date_time, (int, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone//60, 60) + '"'
Example 6
Project: ArcREST Author: Esri File: general.py License: Apache License 2.0 | 6 votes |
def local_time_to_online(dt=None): """ converts datetime object to a UTC timestamp for AGOL Inputs: dt - datetime object Output: Long value """ if dt is None: dt = datetime.datetime.now() is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = (time.altzone if is_dst else time.timezone) return (time.mktime(dt.timetuple()) * 1000) + (utc_offset *1000) #----------------------------------------------------------------------
Example 7
Project: yaql Author: openstack File: date_time.py License: Apache License 2.0 | 6 votes |
def localtz(): """:yaql:localtz Returns local time zone in timespan object. :signature: localtz() :returnType: timespan object .. code:: yaql> localtz().hours 3.0 """ if python_time.daylight: return TIMESPAN_TYPE(seconds=-python_time.altzone) else: return TIMESPAN_TYPE(seconds=-python_time.timezone)
Example 8
Project: Gurux.DLMS.Python Author: Gurux File: GXDateTime.py License: GNU General Public License v2.0 | 5 votes |
def __init__(self, value=None, pattern=None): """ Constructor. value: Date-time value. pattern: Date-time pattern that is used when value is a string. """ self.extra = DateTimeExtraInfo.NONE self.skip = DateTimeSkips.NONE self.status = ClockStatus.OK self.timeZone = 0 self.dayOfWeek = 0 if isinstance(value, datetime.datetime): if value.tzinfo is None: self.value = datetime.datetime(value.year, value.month, value.day, value.hour, value.minute, value.second, 0, tzinfo=GXTimeZone(int(-time.altzone / 60))) else: self.value = value elif isinstance(value, str): self.value = self.fromString(value, pattern) elif isinstance(value, GXDateTime): self.value = value.value self.skip = value.skip self.extra = value.extra elif not value: self.value = None else: raise ValueError("Invalid datetime value.")
Example 9
Project: verge3d-blender-addon Author: Soft8Soft File: utils.py License: GNU General Public License v3.0 | 5 votes |
def localtime(dt=None, isdst=-1): """Return local time as an aware datetime object. If called without arguments, return current time. Otherwise *dt* argument should be a datetime instance, and it is converted to the local time zone according to the system time zone database. If *dt* is naive (that is, dt.tzinfo is None), it is assumed to be in local time. In this case, a positive or zero value for *isdst* causes localtime to presume initially that summer time (for example, Daylight Saving Time) is or is not (respectively) in effect for the specified time. A negative value for *isdst* causes the localtime() function to attempt to divine whether summer time is in effect for the specified time. """ if dt is None: return datetime.datetime.now(datetime.timezone.utc).astimezone() if dt.tzinfo is not None: return dt.astimezone() # We have a naive datetime. Convert to a (localtime) timetuple and pass to # system mktime together with the isdst hint. System mktime will return # seconds since epoch. tm = dt.timetuple()[:-1] + (isdst,) seconds = time.mktime(tm) localtm = time.localtime(seconds) try: delta = datetime.timedelta(seconds=localtm.tm_gmtoff) tz = datetime.timezone(delta, localtm.tm_zone) except AttributeError: # Compute UTC offset and compare with the value implied by tm_isdst. # If the values match, use the zone name implied by tm_isdst. delta = dt - datetime.datetime(*time.gmtime(seconds)[:6]) dst = time.daylight and localtm.tm_isdst > 0 gmtoff = -(time.altzone if dst else time.timezone) if delta == datetime.timedelta(seconds=gmtoff): tz = datetime.timezone(delta, time.tzname[dst]) else: tz = datetime.timezone(delta) return dt.replace(tzinfo=tz)
Example 10
Project: misp42splunk Author: remg427 File: utils.py License: GNU Lesser General Public License v3.0 | 5 votes |
def localtime(dt=None, isdst=-1): """Return local time as an aware datetime object. If called without arguments, return current time. Otherwise *dt* argument should be a datetime instance, and it is converted to the local time zone according to the system time zone database. If *dt* is naive (that is, dt.tzinfo is None), it is assumed to be in local time. In this case, a positive or zero value for *isdst* causes localtime to presume initially that summer time (for example, Daylight Saving Time) is or is not (respectively) in effect for the specified time. A negative value for *isdst* causes the localtime() function to attempt to divine whether summer time is in effect for the specified time. """ if dt is None: return datetime.datetime.now(datetime.timezone.utc).astimezone() if dt.tzinfo is not None: return dt.astimezone() # We have a naive datetime. Convert to a (localtime) timetuple and pass to # system mktime together with the isdst hint. System mktime will return # seconds since epoch. tm = dt.timetuple()[:-1] + (isdst,) seconds = time.mktime(tm) localtm = time.localtime(seconds) try: delta = datetime.timedelta(seconds=localtm.tm_gmtoff) tz = datetime.timezone(delta, localtm.tm_zone) except AttributeError: # Compute UTC offset and compare with the value implied by tm_isdst. # If the values match, use the zone name implied by tm_isdst. delta = dt - datetime.datetime(*time.gmtime(seconds)[:6]) dst = time.daylight and localtm.tm_isdst > 0 gmtoff = -(time.altzone if dst else time.timezone) if delta == datetime.timedelta(seconds=gmtoff): tz = datetime.timezone(delta, time.tzname[dst]) else: tz = datetime.timezone(delta) return dt.replace(tzinfo=tz)
Example 11
Project: misp42splunk Author: remg427 File: utils.py License: GNU Lesser General Public License v3.0 | 5 votes |
def localtime(dt=None, isdst=-1): """Return local time as an aware datetime object. If called without arguments, return current time. Otherwise *dt* argument should be a datetime instance, and it is converted to the local time zone according to the system time zone database. If *dt* is naive (that is, dt.tzinfo is None), it is assumed to be in local time. In this case, a positive or zero value for *isdst* causes localtime to presume initially that summer time (for example, Daylight Saving Time) is or is not (respectively) in effect for the specified time. A negative value for *isdst* causes the localtime() function to attempt to divine whether summer time is in effect for the specified time. """ if dt is None: return datetime.datetime.now(datetime.timezone.utc).astimezone() if dt.tzinfo is not None: return dt.astimezone() # We have a naive datetime. Convert to a (localtime) timetuple and pass to # system mktime together with the isdst hint. System mktime will return # seconds since epoch. tm = dt.timetuple()[:-1] + (isdst,) seconds = time.mktime(tm) localtm = time.localtime(seconds) try: delta = datetime.timedelta(seconds=localtm.tm_gmtoff) tz = datetime.timezone(delta, localtm.tm_zone) except AttributeError: # Compute UTC offset and compare with the value implied by tm_isdst. # If the values match, use the zone name implied by tm_isdst. delta = dt - datetime.datetime(*time.gmtime(seconds)[:6]) dst = time.daylight and localtm.tm_isdst > 0 gmtoff = -(time.altzone if dst else time.timezone) if delta == datetime.timedelta(seconds=gmtoff): tz = datetime.timezone(delta, time.tzname[dst]) else: tz = datetime.timezone(delta) return dt.replace(tzinfo=tz)
Example 12
Project: plugin.video.emby Author: MediaBrowser File: tz.py License: GNU General Public License v3.0 | 5 votes |
def __init__(self): super(tzlocal, self).__init__() self._std_offset = datetime.timedelta(seconds=-time.timezone) if time.daylight: self._dst_offset = datetime.timedelta(seconds=-time.altzone) else: self._dst_offset = self._std_offset self._dst_saved = self._dst_offset - self._std_offset self._hasdst = bool(self._dst_saved) self._tznames = tuple(time.tzname)
Example 13
Project: recruit Author: Frank-qlu File: tz.py License: Apache License 2.0 | 5 votes |
def __init__(self): super(tzlocal, self).__init__() self._std_offset = datetime.timedelta(seconds=-time.timezone) if time.daylight: self._dst_offset = datetime.timedelta(seconds=-time.altzone) else: self._dst_offset = self._std_offset self._dst_saved = self._dst_offset - self._std_offset self._hasdst = bool(self._dst_saved) self._tznames = tuple(time.tzname)
Example 14
Project: script.tvguide.fullscreen Author: primaeval File: source.py License: GNU General Public License v2.0 | 5 votes |
def parseXMLTVDate(self, origDateString): # get timezone information dateParts = origDateString.split() offSign = "+" if len(dateParts) == 2: dateString = dateParts[0] offset = dateParts[1] if len(offset) == 5: offSign = offset[0] offHrs = int(offset[1:3]) offMins = int(offset[-2:]) td = datetime.timedelta(minutes=offMins, hours=offHrs) else: td = datetime.timedelta(seconds=0) elif len(dateParts) <= 1: dateString = dateParts[0] td = datetime.timedelta(seconds=0) else: return None # normalize the given time to UTC by applying the timedelta provided in the timestamp try: t_tmp = datetime.datetime.strptime(dateString, '%Y%m%d%H%M%S') except TypeError: xbmc.log('[script.tvguide.fullscreen] strptime error with this date: %s' % dateString, xbmc.LOGDEBUG) t_tmp = datetime.datetime.fromtimestamp(time.mktime(time.strptime(dateString, '%Y%m%d%H%M%S'))) if offSign == '+': t = t_tmp - td elif offSign == '-': t = t_tmp + td else: t = t_tmp # get the local timezone offset in seconds is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = - (time.altzone if is_dst else time.timezone) td_local = datetime.timedelta(seconds=utc_offset) t = t + td_local return t
Example 15
Project: script.tvguide.fullscreen Author: primaeval File: source.py License: GNU General Public License v2.0 | 5 votes |
def local_time_offset(self,t=None): """Return offset of local zone from GMT, either at present or at time t.""" # python2.3 localtime() can't take None if t is None: t = time.time() if time.localtime(t).tm_isdst and time.daylight: return -time.altzone else: return -time.timezone
Example 16
Project: script.tvguide.fullscreen Author: primaeval File: source.py License: GNU General Public License v2.0 | 5 votes |
def updateSchedules(self, ch_list, progress_callback): sd = SdAPI() station_ids = [] for ch in ch_list: station_ids.append(ch.id) # make sure date is in UTC! date_local = datetime.datetime.now() is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = time.altzone if is_dst else time.timezone td_utc = datetime.timedelta(seconds=utc_offset) date = date_local + td_utc xbmc.log("[%s] Local date '%s' converted to UTC '%s'" % (ADDON.getAddonInfo('id'), str(date_local), str(date)), xbmc.LOGDEBUG) # [{'station_id': station_id, 'p_id': p_id, 'start': start, # 'dur': dur, 'title': 'abc', 'desc': 'abc', 'logo': ''}, ... ] elements_parsed = 0 schedules = sd.get_schedules(station_ids, date, progress_callback) for prg in schedules: start = self.to_local(prg['start']) end = start + datetime.timedelta(seconds=int(prg['dur'])) result = Program(prg['station_id'], prg['title'], '', start, end, prg['desc'],'', imageSmall=prg['logo']) elements_parsed += 1 if result: if progress_callback and elements_parsed % 100 == 0: percent = 100.0 / len(schedules) * elements_parsed if not progress_callback(percent): raise SourceUpdateCanceledException() yield result
Example 17
Project: script.tvguide.fullscreen Author: primaeval File: source.py License: GNU General Public License v2.0 | 5 votes |
def to_local(time_str): # format: 2016-08-21T00:45:00Z try: utc = datetime.datetime.strptime(time_str, '%Y-%m-%dT%H:%M:%SZ') except TypeError: utc = datetime.datetime.fromtimestamp( time.mktime(time.strptime(time_str, '%Y-%m-%dT%H:%M:%SZ'))) # get the local timezone offset in seconds is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = - (time.altzone if is_dst else time.timezone) td_local = datetime.timedelta(seconds=utc_offset) t_local = utc + td_local return t_local
Example 18
Project: script.tvguide.fullscreen Author: primaeval File: source.py License: GNU General Public License v2.0 | 5 votes |
def parseXMLTVDate(self, origDateString): #BUG http://forum.kodi.tv/showthread.php?tid=112916 try: t = datetime.datetime.strptime(origDateString, '%Y%m%d%H%M%S') except TypeError: t = datetime.datetime(*(time.strptime(origDateString, '%Y%m%d%H%M%S')[0:6])) # get the local timezone offset in seconds is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = - (time.altzone if is_dst else time.timezone) td_local = datetime.timedelta(seconds=utc_offset) t = t + td_local return t
Example 19
Project: insightconnect-plugins Author: rapid7 File: trigger.py License: MIT License | 5 votes |
def time_set(self): is_dst = time.daylight and time.localtime().tm_isdst > 0 utc_offset = - (time.altzone if is_dst else time.timezone) timezone = time.tzname[time.daylight] time_now = str(datetime.datetime.now(dateutil.tz.tzoffset(timezone, utc_offset))).replace(' ', 'T') self.logger.info(utc_offset) self.logger.info(time.timezone) return time_now
Example 20
Project: GTDWeb Author: lanbing510 File: tzinfo.py License: GNU General Public License v2.0 | 5 votes |
def utcoffset(self, dt): if self._isdst(dt): return timedelta(seconds=-time.altzone) else: return timedelta(seconds=-time.timezone)
Example 21
Project: GTDWeb Author: lanbing510 File: tzinfo.py License: GNU General Public License v2.0 | 5 votes |
def dst(self, dt): if self._isdst(dt): return timedelta(seconds=-time.altzone) - timedelta(seconds=-time.timezone) else: return timedelta(0)
Example 22
Project: GTDWeb Author: lanbing510 File: timezone.py License: GNU General Public License v2.0 | 5 votes |
def __init__(self): self.STDOFFSET = timedelta(seconds=-_time.timezone) if _time.daylight: self.DSTOFFSET = timedelta(seconds=-_time.altzone) else: self.DSTOFFSET = self.STDOFFSET self.DSTDIFF = self.DSTOFFSET - self.STDOFFSET tzinfo.__init__(self)
Example 23
Project: meddle Author: glmcdona File: imaplib.py License: MIT License | 5 votes |
def Time2Internaldate(date_time): """Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time (as returned by time.localtime()), or a double-quoted string. In the last case, it is assumed to already be in the correct format. """ if isinstance(date_time, (int, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone//60, 60) + '"'
Example 24
Project: bitmask-dev Author: leapcode File: gateways.py License: GNU General Public License v3.0 | 5 votes |
def _get_local_offset(self): ''' Return the distance between GMT and the local timezone. :rtype: int ''' local_offset = time.timezone if time.daylight: local_offset = time.altzone return -local_offset / 3600
Example 25
Project: ironpython2 Author: IronLanguages File: imaplib.py License: Apache License 2.0 | 5 votes |
def Time2Internaldate(date_time): """Convert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time (as returned by time.localtime()), or a double-quoted string. In the last case, it is assumed to already be in the correct format. """ if isinstance(date_time, (int, long, float)): tt = time.localtime(date_time) elif isinstance(date_time, (tuple, time.struct_time)): tt = date_time elif isinstance(date_time, str) and (date_time[0],date_time[-1]) == ('"','"'): return date_time # Assume in correct format else: raise ValueError("date_time not of a known type") dt = time.strftime("%d-%b-%Y %H:%M:%S", tt) if dt[0] == '0': dt = ' ' + dt[1:] if time.daylight and tt[-1]: zone = -time.altzone else: zone = -time.timezone return '"' + dt + " %+03d%02d" % divmod(zone//60, 60) + '"'
Example 26
Project: ironpython2 Author: IronLanguages File: test_email.py License: Apache License 2.0 | 5 votes |
def setUp(self): fp = openfile('PyBanner048.gif') try: data = fp.read() finally: fp.close() container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY') image = MIMEImage(data, name='dingusfish.gif') image.add_header('content-disposition', 'attachment', filename='dingusfish.gif') intro = MIMEText('''\ Hi there, This is the dingus fish. ''') container.attach(intro) container.attach(image) container['From'] = 'Barry <barry@digicool.com>' container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>' container['Subject'] = 'Here is your dingus fish' now = 987809702.54848599 timetuple = time.localtime(now) if timetuple[-1] == 0: tzsecs = time.timezone else: tzsecs = time.altzone if tzsecs > 0: sign = '-' else: sign = '+' tzoffset = ' %s%04d' % (sign, tzsecs // 36) container['Date'] = time.strftime( '%a, %d %b %Y %H:%M:%S', time.localtime(now)) + tzoffset self._msg = container self._im = image self._txt = intro
Example 27
Project: ironpython2 Author: IronLanguages File: test_email_renamed.py License: Apache License 2.0 | 5 votes |
def setUp(self): fp = openfile('PyBanner048.gif') try: data = fp.read() finally: fp.close() container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY') image = MIMEImage(data, name='dingusfish.gif') image.add_header('content-disposition', 'attachment', filename='dingusfish.gif') intro = MIMEText('''\ Hi there, This is the dingus fish. ''') container.attach(intro) container.attach(image) container['From'] = 'Barry <barry@digicool.com>' container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>' container['Subject'] = 'Here is your dingus fish' now = 987809702.54848599 timetuple = time.localtime(now) if timetuple[-1] == 0: tzsecs = time.timezone else: tzsecs = time.altzone if tzsecs > 0: sign = '-' else: sign = '+' tzoffset = ' %s%04d' % (sign, tzsecs // 36) container['Date'] = time.strftime( '%a, %d %b %Y %H:%M:%S', time.localtime(now)) + tzoffset self._msg = container self._im = image self._txt = intro
Example 28
Project: ironpython2 Author: IronLanguages File: test_ssl.py License: Apache License 2.0 | 5 votes |
def utc_offset(): #NOTE: ignore issues like #1647654 # local time = utc time + utc offset if time.daylight and time.localtime().tm_isdst > 0: return -time.altzone # seconds return -time.timezone
Example 29
Project: ironpython2 Author: IronLanguages File: test_time.py License: Apache License 2.0 | 5 votes |
def test_dst(self): if time.daylight and time.altzone != time.timezone: self.assertEqual(time.altzone, time.timezone-3600) t = time.time() self.assertEqual(time.mktime(time.gmtime(t))-time.mktime(time.localtime(t)), time.timezone)
Example 30
Project: faces Author: skarlekar File: tz.py License: GNU General Public License v2.0 | 5 votes |
def __init__(self): super(tzlocal, self).__init__() self._std_offset = datetime.timedelta(seconds=-time.timezone) if time.daylight: self._dst_offset = datetime.timedelta(seconds=-time.altzone) else: self._dst_offset = self._std_offset self._dst_saved = self._dst_offset - self._std_offset self._hasdst = bool(self._dst_saved)