跳转到主要内容

计算和转换时区和主要城市的时间。

项目描述

https://github.com/dakrauth/when/actions/workflows/test.yml/badge.svg

安装

从PyPI安装

$ pip install when

或使用 pipx

$ pipx install when

$ pipx install git+https://github.com/dakrauth/when.git

使用方法

要访问城市名称,您必须安装城市数据库

when --db

您可以通过添加 --size SIZE 来指定最小城市大小,其中 SIZE 可以是以下之一

  • 15000 - 人口大于15000的城市或首都

  • 5000 - 人口大于5000或第一级行政区首府,例如美国州

  • 1000 - 人口大于1000或第三级行政区首府

  • 500 - 人口大于500或第四级行政区首府

此外,您可以使用 --pop POP 过滤非行政区首府。

将适当的GeoNames gazetteer下载并生成一个Sqlite数据库。一旦安装,您就可以搜索数据库

$ when --db --search New York
5106292, West New York, West New York, US, New Jersey, America/New_York
5128581, New York City, New York City, US, New York, America/New_York

此外,您可以添加别名。在上面的示例中,我们看到纽约市有GeoNames ID为5128581。将其传递给 --alias 选项,以及您希望使用的另一个名称

$ when --db --alias 5128581 NYC
$ when --source NYC
2023-07-06 07:58:33-0400 (EDT, America/New_York) 187d27w (New York City, New York, US)[🌕 Full Moon]

示例

$ when
2023-07-06 20:58:02+0900 (KST, Asia/Seoul) 187d27w [🌕 Full Moon]

$ when --source CST
2023-07-06 06:58:54-0500 (CDT, Central Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 15:58:54+0400 (+04, Caucasus Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 19:58:54+0800 (CST, China Standard Time) 187d27w [🌕 Full Moon]
2023-07-06 07:58:54-0400 (CDT, Cuba Standard Time) 187d27w [🌕 Full Moon]

$ when --source Paris
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Villeparisis, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Paris, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 13:59:25+0200 (CEST, Europe/Paris) 187d27w (Cormeilles-en-Parisis, Île-de-France, FR)[🌕 Full Moon]
2023-07-06 07:59:25-0400 (EDT, America/Port-au-Prince) 187d27w (Fond Parisien, Ouest, HT)[🌕 Full Moon]
2023-07-06 06:59:25-0500 (CDT, America/Chicago) 187d27w (Paris, Texas, US)[🌕 Full Moon]

$ when --source "San Francisco,US" --target America/New_York Mar 7 1945 7:00pm
1945-03-07 22:00:00-0400 (EWT, America/New_York) 066d10w [🌘 Waning Crescent]
1945-03-07 22:00:00-0400 (EWT, America/New_York) 066d10w [🌘 Waning Crescent]

开发

需求 Python 3.8+

$ git clone git@github.com:dakrauth/when.git
$ cd when
$ python -mvenv venv
$ . venv/bin/activate
$ pip install .
$ when --help
$ when --db
$ pip install tox
$ tox

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解更多关于 安装包 的信息。

源代码分发

when-3.2.0.tar.gz (23.4 kB 查看哈希值)

上传时间 源代码

构建分发

when-3.2.0-py3-none-any.whl (22.0 kB 查看哈希值)

上传时间 Python 3

由以下组织支持