當前位置: 首頁>>代碼示例>>Python>>正文


Python datetime.py方法代碼示例

本文整理匯總了Python中datetime.datetime.py方法的典型用法代碼示例。如果您正苦於以下問題:Python datetime.py方法的具體用法?Python datetime.py怎麽用?Python datetime.py使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在datetime.datetime的用法示例。


在下文中一共展示了datetime.py方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: enfold

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import py [as 別名]
def enfold(dt, fold=1):
        """
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        .. versionadded:: 2.6.0
        """
        return dt.replace(fold=fold) 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:21,代碼來源:_common.py

示例2: is_ambiguous

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import py [as 別名]
def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        .. versionadded:: 2.6.0
        """

        dt = dt.replace(tzinfo=self)

        wall_0 = enfold(dt, fold=0)
        wall_1 = enfold(dt, fold=1)

        same_offset = wall_0.utcoffset() == wall_1.utcoffset()
        same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)

        return same_dt and not same_offset 
開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:26,代碼來源:_common.py

示例3: enfold

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import py [as 別名]
def enfold(dt, fold=1):
        """
        Provides a unified interface for assigning the ``fold`` attribute to
        datetimes both before and after the implementation of PEP-495.

        :param fold:
            The value for the ``fold`` attribute in the returned datetime. This
            should be either 0 or 1.

        :return:
            Returns an object for which ``getattr(dt, 'fold', 0)`` returns
            ``fold`` for all versions of Python. In versions prior to
            Python 3.6, this is a ``_DatetimeWithFold`` object, which is a
            subclass of :py:class:`datetime.datetime` with the ``fold``
            attribute added, if ``fold`` is 1.

        ..versionadded:: 2.6.0
        """
        return dt.replace(fold=fold) 
開發者ID:skarlekar,項目名稱:faces,代碼行數:21,代碼來源:_common.py

示例4: is_ambiguous

# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import py [as 別名]
def is_ambiguous(self, dt):
        """
        Whether or not the "wall time" of a given datetime is ambiguous in this
        zone.

        :param dt:
            A :py:class:`datetime.datetime`, naive or time zone aware.


        :return:
            Returns ``True`` if ambiguous, ``False`` otherwise.

        ..versionadded:: 2.6.0
        """

        dt = dt.replace(tzinfo=self)

        wall_0 = enfold(dt, fold=0)
        wall_1 = enfold(dt, fold=1)

        same_offset = wall_0.utcoffset() == wall_1.utcoffset()
        same_dt = wall_0.replace(tzinfo=None) == wall_1.replace(tzinfo=None)
        
        return same_dt and not same_offset 
開發者ID:skarlekar,項目名稱:faces,代碼行數:26,代碼來源:_common.py


注:本文中的datetime.datetime.py方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。