Duration supports custom formatting, exact parsing and finite limits
- Status
- Fixed
- Fixed in
- v26.10.1
- Area
- compiler
- Source discussion
- https://forum.objo.dev/d/1207-duration-lacks-format-strings-for-tostring
- Last updated
- 2026-10-05
Upvotes
0 upvotes
Uses your Objo forum account.
Public summary
Add custom formatting, exact text parsing and finite value limits to Duration, using the same familiar API patterns as Objo's other value types.
Developers should be able to choose a duration's display precision, format it for a particular locale, and restore the exact original value from its text representation. Add ToString(format) and ToString(format, locale), shared Parse and TryParse methods, and read-only shared MinValue and MaxValue properties.
Keep the existing parameterless ToString() output compatible. Provide an explicit round-trip format and support Infinite as a printable, parseable sentinel. Invalid formats and invalid input should use Objo's normal catchable exceptions; TryParse should provide a Boolean alternative.