Hacker News 中文摘要

RSS订阅

Bttf是一款命令行日期时间多功能工具 -- Bttf is a command line datetime Swiss army knife

文章摘要

bttf是一个命令行工具,用于处理日期时间运算、解析和格式化等操作。它提供用户指南和帮助命令说明,支持MIT和UNLICENSE双许可协议,可输出当前时间等常用功能,并与其他类似工具进行了比较。

文章总结

项目名称:GitHub - BurntSushi/bttf:命令行日期时间处理工具

核心功能: - 日期时间运算(如加减周/月/年) - 多种格式解析与格式化(支持RFC3339、自定义格式等) - 时区转换(如转换到亚洲/曼谷时间) - 时间序列生成(如生成未来5个工作日) - 持续时间计算(如计算从某日期至今的时长)

特色功能: 1. 多时区支持 bash $ bttf time in Asia/Bangkok now 2. 智能时间表达式 bash $ bttf time add '1 week, 12 hours ago' now 3. 日志时间戳转换 bash $ bttf tag lines /tmp/access.log | bttf time in system

安装方式: - 预编译二进制文件(Windows/macOS/Linux) - Rust用户可通过Cargo安装: bash cargo install bttf # 支持本地化功能 cargo install bttf --features locale

技术特点: - 基于Rust生态构建 - 核心逻辑由Jiff库提供 - 本地化支持通过ICU4X实现 - 支持生成静态可执行文件

注意事项: - 不兼容POSIX date命令 - 开发阶段可能存在破坏性变更 - 需配置BTTF_LOCALE环境变量实现本地化

典型应用场景: - 计算项目周期:bttf span since 2025-01-20T12:00 - 生成会议时间表:bttf time seq monthly -w 2-tue - 分析Git提交记录:git ls-files | bttf tag exec git log -n1

文档资源: - 用户指南 - 同类工具对比

开发背景: 作者为解决GNU date使用复杂性问题而开发,同时作为测试Jiff库的实践平台,重点关注实际应用中的API完整性和性能表现。

评论总结

以下是评论内容的总结:

  1. 功能说明

    • Biff用于终端会话期间的邮件通知设置(评论1)
      "No, Biff informs the system whether you want to be notified when mail arrives during the current terminal session."
    • 有用户提到Biff与dateutils的对比体验(评论3)
      "I am a happy user of dateutils...but I will try out Biff and see which one is more ergonomic."
  2. 技术优势

    • Biff正确处理"民用时间"和"绝对时间"的区别,避免DST问题(评论4)
      "The thing Biff gets right...it treats 'civil time' and 'absolute instants' as different types."
    • 基于Jiff Rust库开发,与TC39的Temporal标准相关(评论4,5)
      "Jiff (the underlying Rust crate) gets this from Temporal in TC39" / "Same dude that made jiff...assuming biff is built on top of jiff."
  3. 历史背景

    • 早期Biff是UCB或BSD的邮件通知工具(评论6)
      "I remember when biff was what we ran in a CSH to be informed of new email."
    • 实际工具名称为"bttf"(Back to the Future的缩写)(评论10)
      "Everyone talking about 'biff' should be aware that it's actually 'bttf'."
  4. 使用案例

    • 作者展示bttf在Git仓库文件时间排序中的高级应用(评论7)
      包含两个完整命令示例,展示时间窗口筛选和格式化功能。
    • 可替代复杂的日期计算脚本(评论8)
      "biff time seq monthly -w 2-tue would have replaced about 40 lines of bash for me."
  5. 开发者评价

    • 对处理日期/时间复杂性的认可(评论9)
      "Respect for programming this...it was full of corner cases and trouble."
    • 对工具实用性的肯定(评论3,9)
      "This tool looks great." / "I will try out Biff..."

注:所有评论均无评分(None),主要围绕工具功能、技术实现和历史背景展开讨论。需注意工具实际名称为bttf而非biff(评论10的纠正)。