Bug 16993 – Documentation for toSimpleString and toString does not explain how they differ
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-20T15:32:36Z
Last change time
2018-01-05T13:30:11Z
Keywords
trivial
Assigned to
Jonathan M Davis
Creator
bachmeil
Comments
Comment #0 by bachmeil — 2016-12-20T15:32:36Z
In the documentation for std.datetime.toString, the only thing there is
"Converts this DateTime to a string."
These two return the same output as far as I can tell:
writeln(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toString);
writeln(DateTime(Date(2010, 7, 4), TimeOfDay(7, 6, 12)).toSimpleString);
There should be an explanation of how they differ so that the reader knows when to use one or the other.
Comment #1 by razvan.nitu1305 — 2017-07-11T08:48:46Z
They don't differ at all. toString just calls toSimpleString and forwards the result.
Comment #2 by issues.dlang — 2017-07-11T10:04:59Z
toString does currently call toSimpleString, but the intention is that if you actually care about the format of the string, you don't use toString. Instead, you use a function like toSimpleString or toISOExtString that's explicit about the format. toString is just intended to convert the type to a user-friendly string, not for specific formatting.
Comment #3 by github-bugzilla — 2017-07-11T12:52:59Z