Skip to content

Modern Chrono TimeSpan ToString

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Date and Time (Chrono) › Chrono Date and Time › TimeSpan.ToString

TimeSpan.ToString

Returns the duration as ISO 8601 text, the same as ToIsoString.

Syntax

TimeSpan.ToString

Examples

#import "std/chrono"
using chrono

print TimeSpan( 1, 2, 3, 4, 5 ).ToString( )        '' P1DT2H3M4.005S
print TimeSpan( 2, 3, 4 ).ToString( )              '' PT2H3M4S
print TimeSpan.FromHours( -2 ).ToString( )         '' -PT2H

'' IDENTICAL TO ToIsoString -- ToString calls it. There is no separate
'' d.hh:mm:ss layout for this type, so anything printing a TimeSpan gets
'' the ISO duration form and it round-trips through ParseIso.

Library: Chrono Date and Time
Category: Date and Time (Chrono)
Documented under: The Members

Clone this wiki locally