/usr/lib/python3/dist-packages/twisted/python
NameSizeModeActions
test/-0755rm
_pydoctortemplates/-0755rm
__pycache__/-0755rm
compat.py169310644editdlrm
components.py141990644editdlrm
constants.py5130644editdlrm
context.py40540644editdlrm
deprecate.py276680644editdlrm
failure.py270070644editdlrm
fakepwd.py67320644editdlrm
filepath.py540230644editdlrm
formmethod.py121070644editdlrm
htmlizer.py36260644editdlrm
lockfile.py80260644editdlrm
log.py223020644editdlrm
logfile.py101190644editdlrm
modules.py267150644editdlrm
monkey.py21640644editdlrm
procutils.py13710644editdlrm
randbytes.py34590644editdlrm
rebuild.py71220644editdlrm
reflect.py204800644editdlrm
release.py11040644editdlrm
roots.py71780644editdlrm
runtime.py59240644editdlrm
sendmsg.py26820644editdlrm
shortcut.py23020644editdlrm
syslog.py36520644editdlrm
systemd.py29870644editdlrm
text.py54170644editdlrm
threadable.py33270644editdlrm
threadpool.py102030644editdlrm
twisted-completion.zsh13710644editdlrm
url.py2440644editdlrm
urlpath.py84470644editdlrm
usage.py345770644editdlrm
util.py274320644editdlrm
versions.py2730644editdlrm
win32.py47940644editdlrm
zippath.py90280644editdlrm
zipstream.py96800644editdlrm
_appdirs.py8200644editdlrm
_inotify.py34960644editdlrm
_pydoctor.py67350644editdlrm
_release.py188790644editdlrm
_shellcomp.py252790644editdlrm
_textattributes.py90970644editdlrm
_tzhelper.py31280644editdlrm
_url.py2280644editdlrm
__init__.py5980644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/python/_tzhelper.py (3128B)
# -*- test-case-name: twisted.python.test.test_tzhelper -*- # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Time zone utilities. """ from datetime import datetime as DateTime, timedelta as TimeDelta, tzinfo as TZInfo from typing import Optional __all__ = [ "FixedOffsetTimeZone", "UTC", ] class FixedOffsetTimeZone(TZInfo): """ Represents a fixed timezone offset (without daylight saving time). @ivar name: A L{str} giving the name of this timezone; the name just includes how much time this offset represents. @ivar offset: A L{TimeDelta} giving the amount of time this timezone is offset. """ def __init__(self, offset: TimeDelta, name: Optional[str] = None) -> None: """ Construct a L{FixedOffsetTimeZone} with a fixed offset. @param offset: a delta representing the offset from UTC. @param name: A name to be given for this timezone. """ self.offset = offset self.name = name @classmethod def fromSignHoursMinutes( cls, sign: str, hours: int, minutes: int ) -> "FixedOffsetTimeZone": """ Construct a L{FixedOffsetTimeZone} from an offset described by sign ('+' or '-'), hours, and minutes. @note: For protocol compatibility with AMP, this method never uses 'Z' @param sign: A string describing the positive or negative-ness of the offset. @param hours: The number of hours in the offset. @param minutes: The number of minutes in the offset @return: A time zone with the given offset, and a name describing the offset. """ name = "%s%02i:%02i" % (sign, hours, minutes) if sign == "-": hours = -hours minutes = -minutes elif sign != "+": raise ValueError(f"Invalid sign for timezone {sign!r}") return cls(TimeDelta(hours=hours, minutes=minutes), name) @classmethod def fromLocalTimeStamp(cls, timeStamp: float) -> "FixedOffsetTimeZone": """ Create a time zone with a fixed offset corresponding to a time stamp in the system's locally configured time zone. """ offset = DateTime.fromtimestamp(timeStamp) - DateTime.utcfromtimestamp( timeStamp ) return cls(offset) def utcoffset(self, dt: Optional[DateTime]) -> TimeDelta: """ Return the given timezone's offset from UTC. """ return self.offset def dst(self, dt: Optional[DateTime]) -> TimeDelta: """ Return a zero L{TimeDelta} for the daylight saving time offset, since there is never one. """ return TimeDelta(0) def tzname(self, dt: Optional[DateTime]) -> str: """ Return a string describing this timezone. """ if self.name is not None: return self.name # XXX this is wrong; the tests are dt = DateTime.fromtimestamp(0, self) return dt.strftime("UTC%z") UTC = FixedOffsetTimeZone.fromSignHoursMinutes("+", 0, 0)