<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body>
<p>Em 19.11.2014 12:17, Philippe escreveu:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<p>Em 18.11.2014 10:27, Michael Van Canneyt escreveu:</p>
<blockquote style="padding-left: 5px; border-left: #1010ff  2px  solid; margin-left: 5px; width: 100%;">
<pre>On Tue, 18 Nov 2014, Philippe wrote:</pre>
<blockquote style="padding-left: 5px; border-left: #1010ff  2px  solid; margin-left: 5px; width: 100%;">Em 18.11.2014 09:49, Philippe escreveu: I wrote a program: - windows 8 32 bits - lazarus 1.2.4  ... fpc 2.6.4 then I copied it to another computer - windows 7 64 bits - lazarus 1.0.14 .... fpc 2.6.2 and got into trouble with dates format! programs behave diferent way, and what was working on the fisrt computer does not work properly in the second! I guess I need some tutorial (I looked for but did not find anything :( !) why formatDateTime( 'DD/MM/YYYY', now) returns 18-11-2014 and not 18/11/2014 ?   strtodate( formatDateTime( 'DD/MM/YYYY', now)) works ok on the w 8 32 bits, but arise an exception on the w 7 64 bits.   I am confused with the following syntax function FormatDateTime(   const FormatStr: string;   DateTime: TDateTime;   const FormatSettings: TFormatSettings ):string; how does it work between two format especifications: FormatStr and FormatSettings ? appreciate any example of good programming pratise of data formating to avoid bad surprise moving program from an OS to another ! Philippe   on <a href="http://www.freepascal.org/docs-html/rtl/sysutils/strtodate.html">http://www.freepascal.org/docs-html/rtl/sysutils/strtodate.html</a> I found Program Example19; { This program demonstrates the StrToDate function } Uses sysutils; Procedure TestStr (S : String); begin Writeln (S,' : ',DateToStr(StrToDate(S))); end; Begin Writeln ('ShortDateFormat ',ShortDateFormat); TestStr(DateTimeToStr(Date)); TestStr('05'+DateSeparator+'05'+DateSeparator+'1999'); TestStr('5'+DateSeparator+'5'); TestStr('5'); End. the compiler warns that ShortDateFormat is deprecated ... which is not informed in the doc ...</blockquote>
<pre>It should be, I will check.

Anyway, as Graeme hinted: ShortDateFormat contains a format string, and / is a placeholder for the date 
separator character on the computer on which the program is running.

If you want to force a character, you can enclose it in quotes:
ShortDateFormat:='dd"/"mm"/"yyyy'
will always use / as the date separator, no matter what the internatonalization settings on the PC.

But it is bad practice to do so.

Secondly, it is a common mistake to think that StrToDate will always correctly perform the opposite of DateToStr.
It does not, but this is documented.

Michael.<br /><br /><br /><br />I still don't know how to use at the same time formatStr and FormatSettings in FormatDateTime.<br /><br />I´ll like very much to find a tutorial or some example about the good practice to manage dates and be sure it will do the same thing on different machines ....<br /><br />Thanks<br /><br /><br />interesting stuff ... but ... out of date!!!! using deprecatings ... (from year 2000 !!!) ... does not help much!!!<br /><br />http://www.math.uni-leipzig.de/pool/tuts/FreePascal/units/node21.html#SECTION002141000000000000000<br /><br /></pre>
<br />
<pre>_______________________________________________
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<p> </p>
<!-- html ignored --><br />
<pre>_______________________________________________
fpc-pascal maillist  -  <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
<p> </p>
</body></html>