A Ruby natural language parser for elapsed time that converts human-readable durations to seconds and vice versa.
Chronic Duration is a Ruby library that parses human-readable time expressions into seconds and formats seconds back into readable durations. It solves the problem of converting informal time descriptions like '2 hrs 20 min' or '3 weeks and 2 days' into precise numeric values for programmatic use, and vice versa.
Ruby developers building applications that need to process user-entered time data, such as time tracking tools, scheduling systems, or any interface where users input durations in natural language.
Developers choose Chronic Duration for its simplicity, flexibility in handling various time formats, and bidirectional conversion capabilities without requiring complex datetime libraries or regex patterns.
A simple Ruby natural language parser for elapsed time
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Handles a wide range of inputs from spelled-out phrases like 'two hours and twenty minutes' to abbreviations like '2h20min', as demonstrated in the README examples.
Supports multiple formats such as short, long, and chrono, with customization options for units, precision, and joiner strings, enabling tailored display.
Offers options like keep_zero, limit_to_hours, and raise_exceptions, allowing developers to fine-tune parsing and output based on application needs.
Provides both parse (text to seconds) and output (seconds to text) methods, making it versatile for processing and displaying durations.
The TODO list explicitly mentions 'Other locale support' as pending, limiting its use in international applications that require non-English time expressions.
As noted in the TODO, it lacks context-specific matching for ambiguous cases like '4m30s' where 'm' could mean minutes or months, leading to potential misinterpretations.
Benchmarking and optimization are listed as TODO items, suggesting the library may not be efficient for high-volume or performance-critical parsing scenarios.
By default, it returns nil on parse errors, which can be silent failures; raising exceptions requires explicit configuration, adding complexity for robust error management.