资源简介
Python 3.7.3中文文档 双击 文档python-3.7.3-docs-html/index.html查看
代码片段和文件信息
from datetime import tzinfo timedelta datetime
ZERO = timedelta(0)
HOUR = timedelta(hours=1)
SECOND = timedelta(seconds=1)
# A class capturing the platform‘s idea of local time.
# (May result in wrong values on historical times in
# timezones where UTC offset and/or the DST rules had
# changed in the past.)
import time as _time
STDOFFSET = timedelta(seconds = -_time.timezone)
if _time.daylight:
DSTOFFSET = timedelta(seconds = -_time.altzone)
else:
DSTOFFSET = STDOFFSET
DSTDIFF = DSTOFFSET - STDOFFSET
class LocalTimezone(tzinfo):
def fromutc(self dt):
assert dt.tzinfo is self
stamp = (dt - datetime(1970 1 1 tzinfo=self)) // SECOND
args = _time.localtime(stamp)[:6]
dst_diff = DSTDIFF // SECOND
# Detect fold
fold = (args == _time.localtime(stamp - dst_diff))
return datetime(*args microsecond=dt.microsecond
tzinfo=self fold=fold)
def utcoffset(self dt):
if self._isdst(dt):
return DSTOFFSET
else:
return STDOFFSET
def dst(self dt):
if self._isdst(dt):
return DSTDIFF
else:
return ZERO
def tzname(self dt):
return _time.tzname[self._isdst(dt)]
def _isdst(self dt):
tt = (dt.year dt.month dt.day
dt.hour dt.minute dt.second
dt.weekday() 0 0)
stamp = _time.mktime(tt)
tt = _time.localtime(stamp)
return tt.tm_isdst > 0
Local = LocalTimezone()
# A complete implementation of current DST rules for major US time zones.
def first_sunday_on_or_after(dt):
days_to_go = 6 - dt.weekday()
if days_to_go:
dt += timedelta(days_to_go)
return dt
# US DST Rules
#
# This is a simplified (i.e. wrong for a few cases) set of rules for US
# DST start and end times. For a complete and up-to-date set of DST rules
# and timezone definitions visit the Olson Database (or try pytz):
# http://www.twinsun.com/tz/tz-link.htm
# http://sourceforge.net/projects/pytz/ (might not be up-to-date)
#
# In the US since 2007 DST starts at 2am (standard time) on the second
# Sunday in March which is the first Sunday on or after Mar 8.
DSTSTART_2007 = datetime(1 3 8 2)
# and ends at 2am (DST time) on the first Sunday of Nov.
DSTEND_2007 = datetime(1 11 1 2)
# From 1987 to 2006 DST used to start at 2am (standard time) on the first
# Sunday in April and to end at 2am (DST time) on the last
# Sunday of October which is the first Sunday on or after Oct 25.
DSTSTART_1987_2006 = datetime(1 4 1 2)
DSTEND_1987_2006 = datetime(1 10 25 2)
# From 1967 to 1986 DST used to start at 2am (standard time) on the last
# Sunday in April (the one on or after April 24) and to end at 2am (DST time)
# on the last Sunday of October which is the first Sunday
# on or after Oct 25.
DSTSTART_1967_1986 = datetime(1 4 24 2)
DSTEND_1967_1986 = DSTEND_1987_2006
def us_dst_range(year):
# Find start 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-09 01:09 python-3.7.3-docs-html\
文件 55478 2019-04-09 01:09 python-3.7.3-docs-html\genindex-T.html
目录 0 2019-02-14 13:30 python-3.7.3-docs-html\_downloads\
目录 0 2019-02-14 13:30 python-3.7.3-docs-html\_downloads\a01ac1c40eb86ec0f9e3c8e80f9eca65\
文件 5860 2019-02-14 13:27 python-3.7.3-docs-html\_downloads\a01ac1c40eb86ec0f9e3c8e80f9eca65\tzinfo_examples.py
文件 10648 2019-04-09 01:09 python-3.7.3-docs-html\genindex-Q.html
文件 107837 2019-04-09 01:09 python-3.7.3-docs-html\ob
目录 0 2019-02-14 13:29 python-3.7.3-docs-html\howto\
文件 146103 2019-04-09 01:01 python-3.7.3-docs-html\howto\regex.html
文件 300840 2019-04-09 01:01 python-3.7.3-docs-html\howto\logging-cookbook.html
文件 108541 2019-04-09 01:01 python-3.7.3-docs-html\howto\logging.html
文件 32483 2019-04-09 01:01 python-3.7.3-docs-html\howto\instrumentation.html
文件 59324 2019-04-09 01:01 python-3.7.3-docs-html\howto\curses.html
文件 76009 2019-04-09 01:01 python-3.7.3-docs-html\howto\unicode.html
文件 81527 2019-04-09 01:01 python-3.7.3-docs-html\howto\argparse.html
文件 9251 2019-04-09 01:01 python-3.7.3-docs-html\howto\index.html
文件 47213 2019-04-09 01:01 python-3.7.3-docs-html\howto\pyporting.html
文件 60129 2019-04-09 01:01 python-3.7.3-docs-html\howto\desc
文件 37660 2019-04-09 01:01 python-3.7.3-docs-html\howto\ipaddress.html
文件 154516 2019-04-09 01:01 python-3.7.3-docs-html\howto\functional.html
文件 40176 2019-04-09 01:01 python-3.7.3-docs-html\howto\sockets.html
文件 72427 2019-04-09 01:01 python-3.7.3-docs-html\howto\urllib2.html
文件 42143 2019-04-09 01:01 python-3.7.3-docs-html\howto\cporting.html
文件 47225 2019-04-09 01:01 python-3.7.3-docs-html\howto\sorting.html
文件 131757 2019-04-09 01:01 python-3.7.3-docs-html\howto\clinic.html
文件 577337 2019-04-09 01:00 python-3.7.3-docs-html\contents.html
目录 0 2019-02-14 13:29 python-3.7.3-docs-html\faq\
文件 59828 2019-04-09 01:01 python-3.7.3-docs-html\faq\extending.html
文件 208717 2019-04-09 01:01 python-3.7.3-docs-html\faq\programming.html
文件 29135 2019-04-09 01:01 python-3.7.3-docs-html\faq\windows.html
文件 8242 2019-04-09 01:01 python-3.7.3-docs-html\faq\index.html
............此处省略1033个文件信息
相关资源
- Python-BDD100K大规模多样化驾驶视频数据
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
川公网安备 51152502000135号
评论
共有 条评论