Skip to content

Commit 6fee696

Browse files
committed
feat: add zone info standard library
1 parent 44a092c commit 6fee696

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

README-zh-cn.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
**二进制数据**: [``codecs``](#codecs), [``struct``](#struct)
4343

44-
**数据类型**: [``datetime``](#datetime), [``calendar``](#calendar), [``collections``](#collections),[``copy``](#copy), [``pprint``](#pprint), [``enum``](#enum), [``bisect``](#bisect), [``heapq``](#heapq), [``weakref``](#weakref)
44+
**数据类型**: [``datetime``](#datetime), [``zoneinfo``](#zoneinfo), [``calendar``](#calendar), [``collections``](#collections),[``copy``](#copy), [``pprint``](#pprint), [``enum``](#enum), [``bisect``](#bisect), [``heapq``](#heapq), [``weakref``](#weakref)
4545

4646
**数学模块**: [``math``](#math), [``cmath``](#cmath), [``random``](#random),
4747
[``fractions``](#fractions), [``decimal``](#decimal), [``statistics``](#statistics)
@@ -386,6 +386,23 @@ datetime.IsoCalendarDate(year=2019, week=29, weekday=7)
386386
'2019 21 19, 00:00:00'
387387
```
388388

389+
## zoneinfo
390+
391+
#### zoneinfo
392+
393+
```python
394+
>>> from zoneinfo import ZoneInfo
395+
>>> from datetime import datetime
396+
>>>
397+
>>> time = datetime(2025, 10, 26, 17, 23, tzinfo = ZoneInfo("Asia/Shanghai"))
398+
>>> time
399+
datetime.datetime(2025, 10, 26, 17, 23, tzinfo=zoneinfo.ZoneInfo(key='Asia/Shanghai'))
400+
>>> time.tzname()
401+
'CST'
402+
>>> time.astimezone(ZoneInfo("America/Los_Angeles"))
403+
datetime.datetime(2025, 10, 26, 2, 23, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles'))
404+
```
405+
389406
## calendar
390407

391408
#### isleap, firstweekday, month

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Fork me on [GitHub](https://github.com/pynickle/python-cheatsheet-redefined).
4242

4343
**Binary Data**: [``codecs``](#codecs), [``struct``](#struct)
4444

45-
**Data Type**: [``datetime``](#datetime), [``calendar``](#calendar), [``collections``](#collections),[``copy``](#copy), [``pprint``](#pprint), [``enum``](#enum), [``bisect``](#bisect), [``heapq``](#heapq), [``weakref``](#weakref)
45+
**Data Type**: [``datetime``](#datetime), [``zoneinfo``](#zoneinfo), [``calendar``](#calendar), [``collections``](#collections),[``copy``](#copy), [``pprint``](#pprint), [``enum``](#enum), [``bisect``](#bisect), [``heapq``](#heapq), [``weakref``](#weakref)
4646

4747
**Mathematical Modules**: [``math``](#math), [``cmath``](#cmath), [``random``](#random),
4848
[``fractions``](#fractions), [``decimal``](#decimal), [``statistics``](#statistics)
@@ -387,6 +387,23 @@ datetime.IsoCalendarDate(year=2019, week=29, weekday=7)
387387
'2019 21 19, 00:00:00'
388388
```
389389

390+
## zoneinfo
391+
392+
#### zoneinfo
393+
394+
```python
395+
>>> from zoneinfo import ZoneInfo
396+
>>> from datetime import datetime
397+
>>>
398+
>>> time = datetime(2025, 10, 26, 17, 23, tzinfo = ZoneInfo("Asia/Shanghai"))
399+
>>> time
400+
datetime.datetime(2025, 10, 26, 17, 23, tzinfo=zoneinfo.ZoneInfo(key='Asia/Shanghai'))
401+
>>> time.tzname()
402+
'CST'
403+
>>> time.astimezone(ZoneInfo("America/Los_Angeles"))
404+
datetime.datetime(2025, 10, 26, 2, 23, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles'))
405+
```
406+
390407
## calendar
391408

392409
#### isleap, firstweekday, month

0 commit comments

Comments
 (0)