Skip to main content

提供JSON-RPC接口的时间服务器,支持获取不同时区的当前时间

Project description

Time Server Package

一个提供JSON-RPC接口的时间服务器Python包,支持获取不同时区的当前时间。

功能特性

  • 提供tools/get_current_time JSON-RPC方法
  • 支持指定时区获取时间
  • 基于FastAPI框架构建
  • 包含命令行入口点

安装

pip install time-server-pkg

使用方法

作为命令行工具运行

time-server

作为Python模块导入

from time_server_pkg import app, get_current_time

# 获取当前时间
print(get_current_time())

# 获取指定时区的时间
print(get_current_time("Asia/Shanghai"))

API接口

服务器默认在http://localhost:8000启动,提供以下JSON-RPC方法:

tools/get_current_time

获取当前时间,可选参数:

  • timezone: 时区字符串,例如"Asia/Shanghai", "America/New_York"

示例请求:

{
  "jsonrpc": "2.0",
  "method": "tools/get_current_time",
  "params": {"timezone": "Asia/Shanghai"},
  "id": 1
}

示例响应:

{
  "jsonrpc": "2.0",
  "result": "2023-11-15 14:30:45 CST",
  "id": 1
}

技术栈

  • Python 3.7+
  • FastAPI
  • Uvicorn
  • pytz

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

time_server_pkg-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

time_server_pkg-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file time_server_pkg-0.1.0.tar.gz.

File metadata

  • Download URL: time_server_pkg-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for time_server_pkg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4217f3d28a78aa7e10f36e84835f68861c92013ae9bf7da8b122fe9252bcb495
MD5 215380f4ffda8c69e20bae5830b78e59
BLAKE2b-256 3bb487e6527ff93299cbaab5beb29f4428980a1f655a8b92a1d464e4e9c56c39

See more details on using hashes here.

File details

Details for the file time_server_pkg-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for time_server_pkg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5572ce4b8f3aa65d62bc8b2cd080e2032cdcd34ec8b565ead0efb8b25ac77fd
MD5 632e8994786c203ce3ceddcf7be59404
BLAKE2b-256 e6d3d2b48b166e46662ec61733c42f921d13c646bcd957277f656fdb91e6cbcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page