Support Japanese time notations in Time.parse and add %JT strftime directives - #26
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB
DateTime %J support and expand_wareki_format already landed upstream; integrate time normalization with PARSE_QUICK_FILTER and verify stdlib out-of-range time behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB
Time.parse picks this up automatically since it calls Date._parse.
Reviewer found strings like '10時間耐久' flip Date.parse from a bogus day-pick to ArgumentError; maintainer approved keeping pure transliteration over a negative-lookahead exclusion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB
Move number format resolution to Utils.number_format so time and date formatting share the padding-flag logic.
Add Time#to_wareki_date and StdExt.expand_all_wareki_formats shared by the Time and DateTime strftime patches.
Follow-ups from final review: pin U+3000 spacing and pre-era Time strftime behavior; document that DateTime.parse bypasses the patched parser. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB
There was a problem hiding this comment.
Code Review
This pull request implements support for parsing and formatting Japanese kansuji and zenkaku time notations (such as '十二時三十四分五十六秒', '午後三時半', and '正午') in Time.parse, Time#strftime, and DateTime#strftime. It introduces %JT* time format directives, adds Time#to_wareki_date, and centralizes number formatting logic in Wareki::Utils. Comprehensive tests, documentation, and design specs have been added to support these changes. As there are no review comments, I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
概要
時刻の日本語表記(漢数字・全角数字の時分秒)のパースとフォーマットをサポートします。日付と違い時刻には元号のようなマッピングが存在しないため、単純な数字変換に徹しています。
設計書:
docs/superpowers/specs/2026-07-13-time-kansuji-support-design.md/ 実装計画:docs/superpowers/plans/2026-07-13-time-kansuji-support.md機能
パース (Time.parse / Date._parse)
日本語時刻表記を等価な ASCII 表記へ「翻字」してから Ruby 標準パーサへ委ねます。
Time.parseは内部でDate._parseを呼ぶため、既存フックの拡張だけで対応され、Time クラスのパースパッチは不要です。"25:00"→ ArgumentError(ASCII と同一挙動)フォーマット (%JT 指示子)
Time#strftime(新規、%J 日付系も併せて対応)とDateTime#strftimeに時刻用の%JT名前空間を追加。Time#to_wareki_dateも追加しています。%JTf(半角複合・0埋めフラグ対応) /%JTF(漢数字複合) /%JTH・%JTHk(時) /%JTM・%JTMk(分) /%JTS・%JTSk(秒)挙動変更(2.0.0 向け・不具合修正扱い)
Date._parse("12時34分56秒")が{mday: 12}ではなく{hour: 12, min: 34, sec: 56}を返すようにDate.parse("12時34分")が当月12日ではなく ArgumentError に(ASCII"12:34"と同一)Time.parseが ArgumentError にDate.parseが数字を日として拾って成功していた文字列がエラーになる場合があります(レビューで検出し、翻字方式の帰結として維持を選択済み。README の制限事項に記載)テスト
class Time追加による Style/OneClassPerFile 1件のみ(Metrics/ModuleLengthMax を 120→170 に引き上げ)🤖 Generated with Claude Code
https://claude.ai/code/session_01JhoiyVcAVMwTk8AgxNFgeB