Dst crypto

Comment

Author: Admin | 2025-04-27

One of these two:return CONSTANT # fixed-offset classreturn CONSTANT + self.dst(dt) # daylight-aware classIf utcoffset() does not return None, dst() should not returnNone either.The default implementation of utcoffset() raisesNotImplementedError.Changed in version 3.7: The UTC offset is not restricted to a whole number of minutes.tzinfo.dst(dt)¶Return the daylight saving time (DST) adjustment, as a timedeltaobject orNone if DST information isn’t known.Return timedelta(0) if DST is not in effect.If DST is in effect, return the offset as a timedelta object(see utcoffset() for details). Note that DST offset, if applicable, hasalready been added to the UTC offset returned by utcoffset(), so there’sno need to consult dst() unless you’re interested in obtaining DST infoseparately. For example, datetime.timetuple() calls its tzinfoattribute’s dst() method to determine how the tm_isdst flagshould be set, and tzinfo.fromutc() calls dst() to account forDST changes when crossing time zones.An instance tz of a tzinfo subclass that models both standard anddaylight times must be consistent in this sense:tz.utcoffset(dt) - tz.dst(dt)must return the same result for every datetime dt with dt.tzinfo ==tz. For sane tzinfo subclasses, this expression yields the timezone’s “standard offset”, which should not depend on the date or the time, butonly on geographic location. The implementation of datetime.astimezone()relies on this, but cannot detect violations; it’s the programmer’sresponsibility to ensure it. If a tzinfo subclass cannot guaranteethis, it may be able to override the default implementation oftzinfo.fromutc() to work correctly with astimezone() regardless.Most implementations of dst() will probably look like one of these two:def dst(self, dt): # a fixed-offset class: doesn't account for DST return timedelta(0)or:def dst(self, dt): # Code to set dston and dstoff to the time zone's DST # transition times based on the input dt.year, and expressed # in standard local time. if dston dt.replace(tzinfo=None) dstoff: return timedelta(hours=1) else: return timedelta(0)The default implementation of dst() raises NotImplementedError.Changed in version 3.7: The DST offset is not restricted to a whole number of minutes.tzinfo.tzname(dt)¶Return the time zone name corresponding to the datetime object dt, asa string. Nothing about string names is defined by the datetime module,and there’s no requirement that it mean anything in particular. For example,"GMT", "UTC", "-500", "-5:00", "EDT", "US/Eastern", "America/New York" are allvalid replies. Return None if a string name isn’t known. Note that this isa method rather than a fixed string primarily because some tzinfosubclasses will wish to return different names depending on the specific valueof dt passed, especially if the tzinfo class is accounting fordaylight time.The default implementation of tzname() raises NotImplementedError.These methods are called by a datetime or time object, inresponse to their methods of the same names. A datetime object passesitself as the argument, and a time object passes None as theargument. A tzinfo subclass’s methods should therefore be prepared toaccept a dt argument

Add Comment