跳转到主要内容

CPython datetime模块的子集

项目描述

简介

Documentation Status Discord Build Status Code Style: Black

基本日期和时间类型。实现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 (59.5 kB 查看哈希值)

上传时间

构建分布

adafruit_circuitpython_datetime-1.2.7-py3-none-any.whl (17.5 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面