timezone-tools
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTimezone Tools
时区工具
Get current time in any timezone and convert times between different timezones using IANA timezone database.
获取任意时区的当前时间,并使用IANA时区数据库在不同时区之间转换时间。
Quick Start
快速开始
Get current time in a timezone
获取指定时区的当前时间
bash
python scripts/get_time.py" "America/New_York"bash
python scripts/get_time.py" "America/New_York"Convert time between timezones
在时区之间转换时间
bash
python scripts/convert_time.py" "America/New_York" "14:30" "Australia/Perth"bash
python scripts/convert_time.py" "America/New_York" "14:30" "Australia/Perth"Search for timezone names
搜索时区名称
bash
python scripts/list_timezones.py" "perth"bash
python scripts/list_timezones.py" "perth"Instructions
使用说明
When the user asks about time or timezones:
-
For current time queries (e.g., "What time is it in Tokyo?"):
- Use with IANA timezone name
scripts/get_time.py - If unsure of timezone name, search first with
list_timezones.py - Script outputs: timezone, datetime, day of week, DST status
- Use
-
For time conversions (e.g., "What's 2pm EST in Perth time?"):
- Use with source timezone, time (HH:MM 24-hour), target timezone
scripts/convert_time.py - Script shows source time, target time, and time difference
- Automatically handles DST changes
- Use
-
For timezone searches:
- Use with city/country name
scripts/list_timezones.py - Returns matching IANA timezone names
- Use
当用户询问时间或时区相关问题时:
-
当前时间查询(例如:“现在东京几点?”):
- 使用并传入IANA时区名称
scripts/get_time.py - 若不确定时区名称,先使用进行搜索
list_timezones.py - 脚本输出:时区、日期时间、星期几、夏令时(DST)状态
- 使用
-
时间转换(例如:“美国东部时间下午2点对应珀斯时间是几点?”):
- 使用并传入源时区、时间(24小时制HH:MM)、目标时区
scripts/convert_time.py - 脚本会显示源时间、目标时间以及时间差
- 自动处理夏令时变更
- 使用
-
时区搜索:
- 使用并传入城市/国家名称
scripts/list_timezones.py - 返回匹配的IANA时区名称
- 使用
Common Timezones Reference
常用时区参考
For quick reference, see data/common_timezones.json which includes major cities worldwide, with Perth prominently featured.
User's local timezone: The scripts automatically detect your local timezone using .
tzlocal如需快速查阅,可查看data/common_timezones.json,其中包含全球主要城市的时区信息,珀斯的时区信息被重点标注。
用户本地时区:脚本会通过自动检测您的本地时区。
tzlocalExamples
示例
Example 1: Current time query
示例1:当前时间查询
User: "What time is it in Perth?"
bash
python scripts/list_timezones.py" "perth"用户:“现在珀斯几点?”
bash
python scripts/list_timezones.py" "perth"Output: Australia/Perth
输出:Australia/Perth
python scripts/get_time.py" "Australia/Perth"
python scripts/get_time.py" "Australia/Perth"
Output:
输出:
Timezone: Australia/Perth
Timezone: Australia/Perth
Current time: 2025-11-07T15:30:45
Current time: 2025-11-07T15:30:45
Day: Thursday
Day: Thursday
DST: No
DST: No
undefinedundefinedExample 2: Time conversion
示例2:时间转换
User: "I have a meeting at 2pm New York time, what time is that in Perth?"
bash
python scripts/convert_time.py" "America/New_York" "14:00" "Australia/Perth"用户:“我在纽约的会议是下午2点,对应珀斯时间是几点?”
bash
python scripts/convert_time.py" "America/New_York" "14:00" "Australia/Perth"Output:
输出:
Source: America/New_York - 2025-11-07T14:00:00 (Thursday, DST: No)
Source: America/New_York - 2025-11-07T14:00:00 (Thursday, DST: No)
Target: Australia/Perth - 2025-11-08T03:00:00 (Friday, DST: No)
Target: Australia/Perth - 2025-11-08T03:00:00 (Friday, DST: No)
Time difference: +13.0h
Time difference: +13.0h
undefinedundefinedExample 3: Multiple timezone search
示例3:多时区搜索
User: "What are the timezone codes for London, Tokyo, and Sydney?"
bash
python scripts/list_timezones.py" "london"
python scripts/list_timezones.py" "tokyo"
python scripts/list_timezones.py" "sydney"用户:“伦敦、东京和悉尼的时区代码是什么?”
bash
python scripts/list_timezones.py" "london"
python scripts/list_timezones.py" "tokyo"
python scripts/list_timezones.py" "sydney"Outputs:
输出:
Europe/London
Europe/London
Asia/Tokyo
Asia/Tokyo
Australia/Sydney
Australia/Sydney
undefinedundefinedTime Format
时间格式
- All times use 24-hour format (HH:MM): not
14:302:30 PM - ISO 8601 datetime format for output:
2025-11-07T14:30:45 - IANA timezone names (e.g., , not
America/New_York)EST
- 所有时间采用24小时制(HH:MM):使用而非
14:302:30 PM - 输出采用ISO 8601日期时间格式:
2025-11-07T14:30:45 - 使用IANA时区名称(例如:,而非
America/New_York)EST
Troubleshooting
故障排除
"Invalid timezone" error
"无效时区"错误
- Use IANA timezone names: not
America/New_YorkorESTEastern - Search with if unsure
list_timezones.py - Check data/common_timezones.json for reference
- 使用IANA时区名称:例如而非
America/New_York或ESTEastern - 若不确定,使用进行搜索
list_timezones.py - 可参考data/common_timezones.json
"Invalid time format" error
"无效时间格式"错误
- Use 24-hour format: not
14:302:30 PM - Format must be with colon separator
HH:MM
- 使用24小时制:例如而非
14:302:30 PM - 格式必须为带冒号分隔符的
HH:MM
Missing dependencies
缺少依赖项
Install required Python packages:
bash
pip install tzlocal安装所需的Python包:
bash
pip install tzlocalDependencies
依赖项
- Python 3.9+
- - for local timezone detection
tzlocal>=5.0 - - built-in Python 3.9+ (IANA timezone database)
zoneinfo
- Python 3.9+
- - 用于检测本地时区
tzlocal>=5.0 - - Python 3.9+内置模块(IANA时区数据库)
zoneinfo
Notes
注意事项
- Scripts automatically handle Daylight Saving Time (DST)
- Local timezone is auto-detected from system
- All timezone data uses IANA Time Zone Database
- Perth, Australia timezone: (UTC+8, no DST)
Australia/Perth
- 脚本会自动处理夏令时(DST)
- 本地时区会从系统自动检测
- 所有时区数据均使用IANA时区数据库
- 澳大利亚珀斯的时区:(UTC+8,无夏令时)
Australia/Perth