View source code
Display the source code in std/datetime/date.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.


Converts this TimeOfDay to a string.

string toString() pure nothrow @safe const;

void toString(W) (
  ref W writer
) const
if (isOutputRange!(W, char));

This function exists to make it easy to convert a TimeOfDay to a string for code that does not care what the exact format is - just that it presents the information in a clear manner. It also makes it easy to simply convert a TimeOfDay to a string when using functions such as to!string, format, or writeln which use toString to convert user-defined types. So, it is unlikely that much code will call toString directly.

The format of the string is purposefully unspecified, and code that cares about the format of the string should use toISOString, toISOExtString, or some other custom formatting function that explicitly generates the format that the code needs. The reason is that the code is then clear about what format it's using, making it less error-prone to maintain the code and interact with other software that consumes the generated strings. It's for this same reason that TimeOfDay has no fromString function, whereas it does have fromISOString and fromISOExtString.

The format returned by toString may or may not change in the future.


writer A char accepting output range


A string when not using an output range; void otherwise.


Jonathan M Davis


Boost License 1.0.