时间计算从未如此简单:passage-of-time-mcp API全方位参考

📅 2026/7/26 12:41:37
时间计算从未如此简单:passage-of-time-mcp API全方位参考
时间计算从未如此简单passage-of-time-mcp API全方位参考【免费下载链接】passage-of-time-mcp️ An MCP server that gives language models temporal awareness and time calculation abilities. Teaching AI the significance of the passage of time through collaborative tool development.项目地址: https://gitcode.com/gh_mirrors/pa/passage-of-time-mcppassage-of-time-mcp是一个为语言模型提供时间感知和时间计算能力的MCP服务器通过协作工具开发让AI理解时间流逝的意义。本文将全方位介绍passage-of-time-mcp的API功能帮助开发者快速掌握时间计算的简单方法。核心功能概览 ️passage-of-time-mcp提供了一系列强大的时间工具涵盖了从获取当前时间到复杂时间计算的各种需求。这些工具通过直观的API接口让时间相关的操作变得简单高效。图1passage-of-time-mcp工具菜单展示了所有可用的时间工具主要工具包括current_datetime获取当前日期和时间time_difference计算两个时间戳之间的差异time_since计算自给定时间戳以来经过的时间parse_timestamp解析并转换时间戳为多种格式add_time在时间戳上添加或减去持续时间timestamp_context获取时间戳的上下文信息format_duration将秒数格式化为可读文本快速开始指南 要开始使用passage-of-time-mcp首先需要克隆仓库git clone https://gitcode.com/gh_mirrors/pa/passage-of-time-mcp项目的核心代码位于passage_of_time_mcp.py文件中包含了所有时间工具的实现。API详细解析 current_datetime获取当前时间current_datetime工具用于获取当前日期和时间支持指定时区。默认时区为America/New_York但可以通过参数指定其他时区。使用示例current_datetime(timezoneUTC)返回结果2024-07-25 12:30:45 UTCtime_difference计算时间差time_difference工具可以计算两个时间戳之间的差异并以多种单位返回结果。时间戳必须采用YYYY-MM-DD HH:MM:SS或YYYY-MM-DD格式。图2time_difference工具详情展示了参数和功能说明使用示例time_difference( timestamp12024-01-15 14:30:00, timestamp22024-01-16 15:45:00, unitauto, timezoneAmerica/New_York )返回结果{ seconds: 87300, formatted: 1 day, 1 hour, 15 minutes, is_negative: false }time_since计算经过时间time_since工具计算从给定时间戳到现在经过的时间并提供人类可读的格式和上下文描述。使用示例time_since(timestamp2024-07-20 09:15:00, timezoneUTC)返回结果{ seconds: 453600, formatted: 5 days, 4 hours ago, context: this week }parse_timestamp解析时间戳parse_timestamp工具将标准格式的时间戳解析并转换为多种格式包括ISO 8601、Unix时间戳和人类友好格式。使用示例parse_timestamp( timestamp2024-07-25 12:30:00, source_timezoneUTC, target_timezoneAsia/Shanghai )返回结果{ iso: 2024-07-25T20:30:0008:00, unix: 1721915400, human: July 25, 2024 at 08:30 PM CST, timezone: Asia/Shanghai, day_of_week: Thursday, date: 2024-07-25, time: 20:30:00 }add_time添加时间add_time工具允许在给定时间戳上添加或减去指定的持续时间支持秒、分钟、小时、天和周等单位。使用示例add_time( timestamp2024-07-25, duration3, unitdays, timezoneUTC )返回结果{ result: 2024-07-28, iso: 2024-07-28T00:00:0000:00, description: next Sunday }timestamp_context时间戳上下文timestamp_context工具提供给定时间戳的上下文信息包括一天中的时间、星期几、是否为周末、是否为工作时间等。使用示例timestamp_context(timestamp2024-07-25 14:30:00, timezoneEurope/London)返回结果{ time_of_day: afternoon, day_of_week: Thursday, is_weekend: false, is_business_hours: true, hour_24: 14, typical_activity: work_time, relative_day: today }format_duration格式化持续时间format_duration工具将秒数格式化为人类可读的文本支持三种不同的风格完整、紧凑和极简。使用示例format_duration(seconds3661, stylefull)返回结果1 hour, 1 minute, 1 second集成指南 passage-of-time-mcp可以轻松集成到各种应用中。在集成页面中你可以看到它与其他服务的连接状态。图3passage-of-time-mcp集成页面显示与其他服务的连接状态要更新集成设置只需编辑名称和URL然后点击Update按钮。图4编辑passage-of-time-mcp集成设置总结passage-of-time-mcp提供了一套全面的时间计算API使复杂的时间操作变得简单直观。无论是获取当前时间、计算时间差还是解析时间戳这些工具都能满足你的需求。通过passage_of_time_mcp.py中提供的功能开发者可以轻松地为应用添加强大的时间感知能力。无论是新手还是有经验的开发者都能快速上手并充分利用这些工具来处理各种时间相关的任务。开始使用passage-of-time-mcp体验时间计算从未如此简单的乐趣【免费下载链接】passage-of-time-mcp️ An MCP server that gives language models temporal awareness and time calculation abilities. Teaching AI the significance of the passage of time through collaborative tool development.项目地址: https://gitcode.com/gh_mirrors/pa/passage-of-time-mcp创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考