小型时区实用程序
atg的Python项目详细描述
$ atg Mountain View Their timezone is "America/Los_Angeles" Their time: Sat Jul 4 07:13:34 2015 People there may be sleeping. Convenient time slots: 08:00 to 11:00 here i.e. 19:30 to 22:30 there 20:30 to 22:30 here i.e. 08:00 to 10:00 there
功能
- Get the timezone for a random address.
- Current time anywhere.
- Guesses about what people may be doing.
- Helps you schedule meetings by providing you spans of convenient times.
安装
这是一个python包,可以通过pip:
# $HOME/.local/bin should be in $PATH for this to work.
$ pip install --user atg
要全局安装,请运行:
$ sudo pip install atg
用法
在mountain view获取有关时间的所有信息:
$ atg Mountain View Their timezone is "America/Los_Angeles" Their time: Sat Jul 4 07:13:34 2015 People there may be sleeping. Convenient time slots: 08:00 to 11:00 here i.e. 19:30 to 22:30 there 20:30 to 22:30 here i.e. 08:00 to 10:00 there
如果你不想每次都查询时区到google的maps api,你可以 可以在进一步的请求中直接使用时区:
$ atg America/Los_Angeles
默认情况下,atg基于计算时隙来避免睡眠周期。你可以 使用--dnd对此进行自定义。例如,为了避免工作/睡眠中的干扰:
$ atg Mountain View --dnd work --dnd sleep
您还可以指定时间段应该方便的对象。默认情况下 两者都要考虑。如果您想方便地为远程位置计时:
$ atg Mountain View -c there
您也可以使用标志--convenient-for标志。如果你不在乎 远程定位的便利性:
$ atg Mountain View --convenient-for here
帮助
您始终可以通过atg -h引用命令用法。
usage: atg [-h] [--dnd {work,sleep,available}] [-c {here,there}] [-m MY_LOCATION] [-x {timezone,now,default,status,schedule}] remote [remote ...] positional arguments: remote the remote location optional arguments: -h, --help show this help message and exit --dnd {work,sleep,available} the do not disturb activities (default: sleep) -c {here,there}, --convenient-for {here,there} which side's convenience should be considered (default: both) -m MY_LOCATION, --my-location MY_LOCATION specify your own location (default from system time) -x {timezone,now,default,status,schedule}, --command {timezone,now,default,status,schedule} the command for atg to execute
开发和测试
atg使用pytz、tzlocal和enum34(用于向后兼容)作为依赖项。
要设置用于开发的内容,请创建并激活一个virtualenv,然后运行
$ pip install -e .[dev,test] $ python setup.py develop
测试
通过以下途径运行测试:
$ nosetests
错误
可能很多。请向我们发送有关githubissue tracker的报告。补丁也很受欢迎。