CPython datetime模块的子集
项目描述
简介
基本日期和时间类型。实现CPython datetime模块的子集。
注意:此库占用大量内存,适用于SAMD51、ESP32-S2和nRF52等硬件。
依赖项
此驱动依赖于
请确保所有依赖项都可在CircuitPython文件系统中使用。这可以通过下载 Adafruit库和驱动程序包 来轻松实现。
从PyPI安装
在支持GNU/Linux系统(如树莓派)上,您可以从PyPI 本地安装驱动程序。为当前用户安装
pip3 install adafruit-circuitpython-datetime
为系统范围安装(在某些情况下可能需要)
sudo pip3 install adafruit-circuitpython-datetime
在当前项目的虚拟环境中安装
mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-datetime
使用示例
# Example of working with a `datetime` object
# from https://docs.pythonlang.cn/3/library/datetime.html#examples-of-usage-datetime
from adafruit_datetime import datetime, date, time
# Using datetime.combine()
d = date(2005, 7, 14)
print(d)
t = time(12, 30)
print(datetime.combine(d, t))
# Using datetime.now()
print("Current time (GMT +1):", datetime.now())
# Using datetime.timetuple() to get tuple of all attributes
dt = datetime(2006, 11, 21, 16, 30)
tt = dt.timetuple()
for it in tt:
print(it)
print("Today is: ", dt.ctime())
iso_date_string = "2020-04-05T05:04:45.752301"
print("Creating new datetime from ISO Date:", iso_date_string)
isodate = datetime.fromisoformat(iso_date_string)
print("Formatted back out as ISO Date: ", isodate.isoformat())
文档
此库的API文档可以在 Read the Docs 上找到。
有关构建库文档的信息,请参阅 本指南。
贡献
欢迎贡献!请在贡献之前阅读我们的 行为准则,以帮助本项目保持友好。
许可
请参阅LICENSE/以获取详细信息。
版权所有 (c) 2001-2021 Python软件基金会。保留所有权利。
版权所有 (c) 2000 BeOpen.com。保留所有权利。
版权所有 (c) 1995-2001 国家研究倡议公司。保留所有权利。
版权所有 (c) 1991-1995 Stichting Mathematisch Centrum。保留所有权利。
项目详情
关闭
adafruit-circuitpython-datetime-1.2.7.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4176cf45a2519dce3a7ad4121d57a9759a1813482b4bea557ace0fcdb9c817cd |
|
MD5 | c28aa3ddda4f983fe73e3ee171a79509 |
|
BLAKE2b-256 | 62b28f27fdb0ecfa655b5fc3a4ffbdb188b7fcf43fa5e449d0916734722d184c |
关闭
adafruit_circuitpython_datetime-1.2.7-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 150184d13f34e2424e47028049b5aeeea3348cb0a8b306798556cb5f7118138e |
|
MD5 | d32182d9fe288db3dd5084f599a0c044 |
|
BLAKE2b-256 | f64456408bf14a70c4363eed2531bf53486cb60457941fbd91c97e2df206ecbe |