Search code examples
datetimestring-formattingc++buildervclc++builder-6

Relation between TDateTime::FormatString and SysUtils::FormatDateTime


When using the TDateTime method FormatString to get a string representation with millisecond-precision, I'm getting perfect results when using the zzzformat specifier. But it is not documented for the TDateTime::FormatString Method, whereas it is for the SysUtils.FormatDateTime Function.

I tried to look up the implementation of the appropriate TDateTime method in the sources, since a duplicate implementation was much less likely than an outdated/out-of-sync documentation.

I found nothing so far. Is there indeed no relation between these both?


Solution

  • [zzz] is not documented for the TDateTime::FormatString Method, whereas it is for the SysUtils.FormatDateTime Function.

    You are looking at old documentation on the old Embarcadero Documents website. The latest TDateTime::FormatString() documentation is available on Embarcadero's newer DocWiki site:

    http://docwiki.embarcadero.com/Libraries/en/System.TDateTime.FormatString

    The zzz specifier was added to the documentation in XE5:

    zzz Displays the milliseconds (000-999).

    I tried to look up the implementation of the appropriate TDateTime method in the sources, since a duplicate implementation was much less likely than an outdated/out-of-sync documentation.

    I found nothing so far. Is there indeed no relation between these both?

    The C++ implementation source code for TDateTime is in the $(BDS)\source\vcl\datetime.cpp file. TDateTime::FormatString() simply calls SysUtils.FormatDateTime() directly:

    System::String __fastcall TDateTime::FormatString(const System::String& format) const
    {
      return Sysutils::FormatDateTime(format, *this);
    }