根据城市名或经纬度坐标,查询该位置的时区 ID、UTC 偏移量以及当前本地时间。
python3 ~/geo-timezone/scripts/geo_timezone.py --city "城市名"
python3 ~/geo-timezone/scripts/geo_timezone.py --lat 纬度 --lon 经度
查询后以如下格式呈现给用户:
📍 位置: Beijing, China
🕐 时区: Asia/Shanghai (CST, UTC+8)
🕒 当前时间: 2025-01-15 14:30:00 (周三)
timezonefinder 库(通过 pip 安装)geopy 库(用于城市名转坐标)pip3 install timezonefinder geopy
用户输入: "纽约现在几点?"
Agent 操作: 执行 python3 ~/geo-timezone/scripts/geo_timezone.py --city "New York"
输出:
📍 位置: New York, United States
🕐 时区: America/New_York (EST, UTC-5)
🕒 当前时间: 2025-01-15 01:30:00 (周三)
共 2 个版本