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

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

示例1: __add__

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def __add__(self, other):

if PY38:

result = datetime(

self.year,

self.month,

self.day,

self.hour,

self.minute,

self.second,

self.microsecond,

self.tzinfo,

).__add__(other)

else:

result = super(DateTime, self).__add__(other)

return self._new(result)

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:18,

示例2: __sub__

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def __sub__(self, other):

if PY38:

result = datetime(

self.year,

self.month,

self.day,

self.hour,

self.minute,

self.second,

self.microsecond,

self.tzinfo,

).__sub__(other)

else:

result = super(DateTime, self).__sub__(other)

if isinstance(result, datetime):

result = self._new(result)

return result

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:21,

示例3: is_ambiguous

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [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,

示例4: _fold_status

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def _fold_status(self, dt_utc, dt_wall):

"""

Determine the fold status of a "wall" datetime, given a representation

of the same datetime as a (naive) UTC datetime. This is calculated based

on the assumption that ``dt.utcoffset() - dt.dst()`` is constant for all

datetimes, and that this offset is the actual number of hours separating

``dt_utc`` and ``dt_wall``.

:param dt_utc:

Representation of the datetime as UTC

:param dt_wall:

Representation of the datetime as "wall time". This parameter must

either have a `fold` attribute or have a fold-naive

:class:`datetime.tzinfo` attached, otherwise the calculation may

fail.

"""

if self.is_ambiguous(dt_wall):

delta_wall = dt_wall - dt_utc

_fold = int(delta_wall == (dt_utc.utcoffset() - dt_utc.dst()))

else:

_fold = 0

return _fold

開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:26,

示例5: _isdst

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def _isdst(self, dt):

if not self.hasdst:

return False

elif dt is None:

return None

transitions = self.transitions(dt.year)

if transitions is None:

return False

dt = dt.replace(tzinfo=None)

isdst = self._naive_isdst(dt, transitions)

# Handle ambiguous dates

if not isdst and self.is_ambiguous(dt):

return not self._fold(dt)

else:

return isdst

開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:22,

示例6: tz_to_dtype

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def tz_to_dtype(tz):

"""

Return a datetime64[ns] dtype appropriate for the given timezone.

Parameters

----------

tz : tzinfo or None

Returns

-------

np.dtype or Datetime64TZDType

"""

if tz is None:

return _NS_DTYPE

else:

return DatetimeTZDtype(tz=tz)

開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,

示例7: _assert_tzawareness_compat

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def _assert_tzawareness_compat(self, other):

# adapted from _Timestamp._assert_tzawareness_compat

other_tz = getattr(other, 'tzinfo', None)

if is_datetime64tz_dtype(other):

# Get tzinfo from Series dtype

other_tz = other.dtype.tz

if other is NaT:

# pd.NaT quacks both aware and naive

pass

elif self.tz is None:

if other_tz is not None:

raise TypeError('Cannot compare tz-naive and tz-aware '

'datetime-like objects.')

elif other_tz is None:

raise TypeError('Cannot compare tz-naive and tz-aware '

'datetime-like objects')

# -----------------------------------------------------------------

# Arithmetic Methods

開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:21,

示例8: is_ambiguous

​點讚 6

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [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,

示例9: __new__

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def __new__(

cls,

year,

month,

day,

hour,

minute,

second,

microsecond,

tzinfo,

trivia,

raw,

**kwargs

): # type: (int, int, int, int, int, int, int, Optional[datetime.tzinfo], Trivia, str, Any) -> datetime

return datetime.__new__(

cls,

year,

month,

day,

hour,

minute,

second,

microsecond,

tzinfo=tzinfo,

**kwargs

)

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:28,

示例10: __init__

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def __init__(

self, year, month, day, hour, minute, second, microsecond, tzinfo, trivia, raw

): # type: (int, int, int, int, int, int, int, Optional[datetime.tzinfo], Trivia, str) -> None

super(DateTime, self).__init__(trivia)

self._raw = raw

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:8,

示例11: _new

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def _new(self, result):

raw = result.isoformat()

return DateTime(

result.year,

result.month,

result.day,

result.hour,

result.minute,

result.second,

result.microsecond,

result.tzinfo,

self._trivia,

raw,

)

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:17,

示例12: _getstate

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def _getstate(self, protocol=3):

return (

self.hour,

self.minute,

self.second,

self.microsecond,

self.tzinfo,

self._trivia,

self._raw,

)

開發者ID:sdispater,項目名稱:tomlkit,代碼行數:12,

示例13: replace

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [as 別名]

def replace(self, *args, **kwargs):

"""

Return a datetime with the same attributes, except for those

attributes given new values by whichever keyword arguments are

specified. Note that tzinfo=None can be specified to create a naive

datetime from an aware datetime with no conversion of date and time

data.

This is reimplemented in ``_DatetimeWithFold`` because pypy3 will

return a ``datetime.datetime`` even if ``fold`` is unchanged.

"""

argnames = (

'year', 'month', 'day', 'hour', 'minute', 'second',

'microsecond', 'tzinfo'

)

for arg, argname in zip(args, argnames):

if argname in kwargs:

raise TypeError('Duplicate argument: {}'.format(argname))

kwargs[argname] = arg

for argname in argnames:

if argname not in kwargs:

kwargs[argname] = getattr(self, argname)

dt_class = self.__class__ if kwargs.get('fold', 1) else datetime

return dt_class(**kwargs)

開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:31,

示例14: enfold

​點讚 5

# 需要導入模塊: from datetime import datetime [as 別名]

# 或者: from datetime.datetime import tzinfo [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

"""

if getattr(dt, 'fold', 0) == fold:

return dt

args = dt.timetuple()[:6]

args += (dt.microsecond, dt.tzinfo)

if fold:

return _DatetimeWithFold(*args)

else:

return datetime(*args)

開發者ID:MediaBrowser,項目名稱:plugin.video.emby,代碼行數:30,

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

python datetime datetime_Python datetime.tzinfo方法代碼示例相关推荐

  1. python template languages_Python template.TemplateSyntaxError方法代碼示例

    本文整理匯總了Python中django.template.TemplateSyntaxError方法的典型用法代碼示例.如果您正苦於以下問題:Python template.TemplateSynt ...

  2. python asyncio future_Python asyncio.ensure_future方法代碼示例

    本文整理匯總了Python中asyncio.ensure_future方法的典型用法代碼示例.如果您正苦於以下問題:Python asyncio.ensure_future方法的具體用法?Python ...

  3. python time strptime_Python time.strptime方法代碼示例

    本文整理匯總了Python中time.strptime方法的典型用法代碼示例.如果您正苦於以下問題:Python time.strptime方法的具體用法?Python time.strptime怎麽 ...

  4. python execute_command err_Python management.execute_from_command_line方法代碼示例

    本文整理匯總了Python中django.core.management.execute_from_command_line方法的典型用法代碼示例.如果您正苦於以下問題:Python manageme ...

  5. python柱状图zzt_Python torch.diag方法代碼示例

    本文整理匯總了Python中torch.diag方法的典型用法代碼示例.如果您正苦於以下問題:Python torch.diag方法的具體用法?Python torch.diag怎麽用?Python ...

  6. python的concatetate_Python tensorflow.truncated_normal_initializer方法代碼示例

    本文整理匯總了Python中tensorflow.truncated_normal_initializer方法的典型用法代碼示例.如果您正苦於以下問題:Python tensorflow.trunca ...

  7. python turtle color_Python turtle.color方法代碼示例

    本文整理匯總了Python中turtle.color方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.color方法的具體用法?Python turtle.color怎麽用?P ...

  8. python psutil.disk_Python psutil.disk_partitions方法代碼示例

    本文整理匯總了Python中psutil.disk_partitions方法的典型用法代碼示例.如果您正苦於以下問題:Python psutil.disk_partitions方法的具體用法?Pyth ...

  9. python querystring encode_Java UriUtils.encodeQueryParam方法代碼示例

    import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類 private URI buildURI(OTXEndpoints ...

最新文章

  1. C#.NET 上传图片时怎样限制文件格式
  2. java正则表达式练习题目
  3. Redis 16 个常见使用场景
  4. UITableView 重用机制
  5. redis 启动无输出_深入剖析Redis系列: Redis入门简介与主从搭建
  6. 数据结构和算法-003 数组排序 选择排序
  7. 我在博客园写博客的原因
  8. 信息论实验一:信源熵的计算
  9. IT人的职业生涯规划
  10. html js手册chm,W3C Javascript CHM参考手册离线版
  11. [转]Unicode汉字编码表
  12. 铅酸电池废水处理技术沉淀+树脂吸附
  13. PPT制作3D绘图(1)
  14. Vue自定义组件之时间跨度选择器
  15. java绘制棋盘_java绘制五子棋棋盘
  16. 企业高管IT战略指南——企业为何要落地DevOps?
  17. OpenCV二值化图像像素操作
  18. 基于ffmpeg+opengl+opensl es的android视频播放器
  19. 记2020年元宵节-我又回来了
  20. Nginx 负载均衡 ip_hash和一致性hash

热门文章

  1. Nginx服务系列——缓存
  2. [Leetcode] Simplify Path
  3. Aspose.Pdf 系列组件介绍
  4. 【转载】拿来即用的企业级安全运维体系搭建指南
  5. 《ArcGIS Runtime SDK for Android开发笔记》——数据制作篇:发布具有同步能力的FeatureService服务...
  6. 从线上教育的如火如荼,反思传统培训行业的未来发展
  7. WinJS实用开发技巧(3):仿微博信息流JK快捷键滚动
  8. pandas中read_csv的缺失值处理方式
  9. java 图片转zpl 数据,使用Zebra 打印机打印
  10. VBScripts and UAC elevation(visa以后的系统)