当前位置: 首页>>代码示例>>Python>>正文


Python object.utcoffset方法代码示例

本文整理汇总了Python中future.builtins.object.utcoffset方法的典型用法代码示例。如果您正苦于以下问题:Python object.utcoffset方法的具体用法?Python object.utcoffset怎么用?Python object.utcoffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在future.builtins.object的用法示例。


在下文中一共展示了object.utcoffset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dst

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def dst(self):
        """Return 0 if DST is not in effect, or the DST offset (in minutes
        eastward) if DST is in effect.

        This is purely informational; the DST offset has already been added to
        the UTC offset returned by utcoffset() if applicable, so there's no
        need to consult dst() unless you're interested in displaying the DST
        info.
        """
        if self._tzinfo is None:
            return None
        offset = self._tzinfo.dst(self)
        _check_utc_offset("dst", offset)
        return offset

    # Comparisons of datetime objects with other. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:18,代码来源:datetime.py

示例2: __sub__

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def __sub__(self, other):
        "Subtract two datetimes, or a datetime and a timedelta."
        if not isinstance(other, datetime):
            if isinstance(other, timedelta):
                return self + -other
            return NotImplemented

        days1 = self.toordinal()
        days2 = other.toordinal()
        secs1 = self._second + self._minute * 60 + self._hour * 3600
        secs2 = other._second + other._minute * 60 + other._hour * 3600
        base = timedelta(days1 - days2,
                         secs1 - secs2,
                         self._microsecond - other._microsecond)
        if self._tzinfo is other._tzinfo:
            return base
        myoff = self.utcoffset()
        otoff = other.utcoffset()
        if myoff == otoff:
            return base
        if myoff is None or otoff is None:
            raise TypeError("cannot mix naive and timezone-aware time")
        return base + otoff - myoff 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:25,代码来源:datetime.py

示例3: _check_tzname

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def _check_tzname(name):
    if name is not None and not isinstance(name, str):
        raise TypeError("tzinfo.tzname() must return None or string, "
                        "not '%s'" % type(name))

# name is the offset-producing method, "utcoffset" or "dst".
# offset is what it returned.
# If offset isn't None or timedelta, raises TypeError.
# If offset is None, returns None.
# Else offset is checked for being in range, and a whole # of minutes.
# If it is, its integer value is returned.  Else ValueError is raised. 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:13,代码来源:datetime.py

示例4: _check_utc_offset

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def _check_utc_offset(name, offset):
    assert name in ("utcoffset", "dst")
    if offset is None:
        return
    if not isinstance(offset, timedelta):
        raise TypeError("tzinfo.%s() must return None "
                        "or timedelta, not '%s'" % (name, type(offset)))
    if offset % timedelta(minutes=1) or offset.microseconds:
        raise ValueError("tzinfo.%s() must return a whole number "
                         "of minutes, got %s" % (name, offset))
    if not -timedelta(1) < offset < timedelta(1):
        raise ValueError("%s()=%s, must be must be strictly between"
                         " -timedelta(hours=24) and timedelta(hours=24)"
                         % (name, offset)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:16,代码来源:datetime.py

示例5: utcoffset

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def utcoffset(self, dt):
        "datetime -> minutes east of UTC (negative for west of UTC)"
        raise NotImplementedError("tzinfo subclass must override utcoffset()") 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:5,代码来源:datetime.py

示例6: _cmp

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def _cmp(self, other, allow_mixed=False):
        assert isinstance(other, time)
        mytz = self._tzinfo
        ottz = other._tzinfo
        myoff = otoff = None

        if mytz is ottz:
            base_compare = True
        else:
            myoff = self.utcoffset()
            otoff = other.utcoffset()
            base_compare = myoff == otoff

        if base_compare:
            return _cmp((self._hour, self._minute, self._second,
                         self._microsecond),
                       (other._hour, other._minute, other._second,
                        other._microsecond))
        if myoff is None or otoff is None:
            if allow_mixed:
                return 2 # arbitrary non-zero value
            else:
                raise TypeError("cannot compare naive and aware times")
        myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
        othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
        return _cmp((myhhmm, self._second, self._microsecond),
                    (othhmm, other._second, other._microsecond)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:29,代码来源:datetime.py

示例7: __hash__

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def __hash__(self):
        """Hash."""
        tzoff = self.utcoffset()
        if not tzoff: # zero or None
            return hash(self._getstate()[0])
        h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
                      timedelta(hours=1))
        assert not m % timedelta(minutes=1), "whole minute"
        m //= timedelta(minutes=1)
        if 0 <= h < 24:
            return hash(time(h, m, self.second, self.microsecond))
        return hash((h, m, self.second, self.microsecond))

    # Conversion to string 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:16,代码来源:datetime.py

示例8: _tzstr

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def _tzstr(self, sep=":"):
        """Return formatted timezone offset (+xx:xx) or None."""
        off = self.utcoffset()
        if off is not None:
            if off.days < 0:
                sign = "-"
                off = -off
            else:
                sign = "+"
            hh, mm = divmod(off, timedelta(hours=1))
            assert not mm % timedelta(minutes=1), "whole minute"
            mm //= timedelta(minutes=1)
            assert 0 <= hh < 24
            off = "%s%02d%s%02d" % (sign, hh, sep, mm)
        return off 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:17,代码来源:datetime.py

示例9: utctimetuple

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def utctimetuple(self):
        "Return UTC time tuple compatible with time.gmtime()."
        offset = self.utcoffset()
        if offset:
            self -= offset
        y, m, d = self.year, self.month, self.day
        hh, mm, ss = self.hour, self.minute, self.second
        return _build_struct_time(y, m, d, hh, mm, ss, 0) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:10,代码来源:datetime.py

示例10: isoformat

# 需要导入模块: from future.builtins import object [as 别名]
# 或者: from future.builtins.object import utcoffset [as 别名]
def isoformat(self, sep='T'):
        """Return the time formatted according to ISO.

        This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if
        self.microsecond == 0.

        If self.tzinfo is not None, the UTC offset is also attached, giving
        'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'.

        Optional argument sep specifies the separator between date and
        time, default 'T'.
        """
        s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day,
                                  sep) +
                _format_time(self._hour, self._minute, self._second,
                             self._microsecond))
        off = self.utcoffset()
        if off is not None:
            if off.days < 0:
                sign = "-"
                off = -off
            else:
                sign = "+"
            hh, mm = divmod(off, timedelta(hours=1))
            assert not mm % timedelta(minutes=1), "whole minute"
            mm //= timedelta(minutes=1)
            s += "%s%02d:%02d" % (sign, hh, mm)
        return s 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:30,代码来源:datetime.py


注:本文中的future.builtins.object.utcoffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。