Board index » delphi » ShortDateFormat ahs no effect in CGI, ISAPI and Console apps

ShortDateFormat ahs no effect in CGI, ISAPI and Console apps


2004-08-05 04:19:05 AM
delphi105
Hello all,
It seems that ShortDateFormat has no effect in CGI, ISAPI and Console apps.
Is there any other way to influence the date/time formatting for these types
of apps? I need to make StrToDatetime working.
TIA
--
Best regards,
Ivan Babikov,
I-Software (www.i-software.narod.ru).
 
 

Re:ShortDateFormat ahs no effect in CGI, ISAPI and Console apps

Try...
DateStr := FormatDateTime('dd-mmm-yyyy', Now);
DaveH
"Ivan Babikov" <XXXX@XXXXX.COM>writes
Quote
Hello all,

It seems that ShortDateFormat has no effect in CGI, ISAPI and Console
apps.
Is there any other way to influence the date/time formatting for these
types
of apps? I need to make StrToDatetime working.

TIA

--
Best regards,
Ivan Babikov,
I-Software (www.i-software.narod.ru).


 

Re:ShortDateFormat ahs no effect in CGI, ISAPI and Console apps

Hi Dave,
Quote
Try...

DateStr := FormatDateTime('dd-mmm-yyyy', Now);
Thanks for the response but if you reread my msg you can see: "I need to make StrToDatetime working." This means that I need to get TDateTime from a string. As I can see there is no "antipode"
for FormatDateTime in Delphi.
Best regards,
Ivan Babikov,
I-Software (www.i-software.narod.ru).
 

Re:ShortDateFormat ahs no effect in CGI, ISAPI and Console apps

Opps.
Here is some old code that I used. It doesn't handle all date formats but
you can tweak it for your own use.
{===========================================================================
==}
function StrToDate(S, Format : string) : TDateTime;
const
MonthNames : array[1..12] of string[3] = ('JAN', 'FEB', 'MAR', 'APR',
'MAY', 'JUN',
'JUL', 'AUG', 'SEP', 'OCT',
'NOV', 'DEC');
var
ChPos : integer;
Year, Month, Day : word;
DateStr : string[10];
Found : boolean;
begin
Result := 0;
S := UpperCase(S);
Format := UpperCase(Format);
try
{decode the year}
ChPos := pos('YYYY', Format);
if ChPos <>0 then
Year := StrToInt(copy(S,ChPos,4))
else
begin
ChPos := pos('YY', Format);
if ChPos <>0 then
Year := StrToInt('19'+copy(S,ChPos,2))
else
exit;
end;
{decode the month}
ChPos := pos('MMM', Format);
if ChPos <>0 then
begin
DateStr := copy(S, ChPos, 3);
Found := false;
Month := 1;
while (not Found) and (Month <= 12) do
if DateStr = MonthNames[Month] then
Found := true
else
inc(Month);
if not Found then
exit;
end
else
begin
ChPos := pos('MM', Format);
if ChPos <>0 then
begin
DateStr := copy(S, ChPos, 2);
if (length(DateStr) = 2) and (not (DateStr[2] in ['0'..'9'])) then
//check if the month was a single digit
DateStr := DateStr[1];
Month := StrToInt(DateStr);
end
else
exit;
end;
{decode the day}
ChPos := pos('DD', Format);
if ChPos <>0 then
begin
DateStr := copy(S, ChPos, 2);
if (length(DateStr) = 2) and (not (DateStr[2] in ['0'..'9'])) then
//check if the day was a single digit
DateStr := DateStr[1];
Day := StrToInt(DateStr);
end
else
Day := 1; //default to the first of the month if no day supplied
{create the TDateTime}
Result := EncodeDate(Year, Month, Day);
except
on EConvertError do
end;
end;
DaveH
"Ivan Babikov" <XXXX@XXXXX.COM>writes
Quote

Hi Dave,

>Try...
>
>DateStr := FormatDateTime('dd-mmm-yyyy', Now);

Thanks for the response but if you reread my msg you can see: "I need to
make StrToDatetime working." This means that I need to get TDateTime
from a string. As I can see there is no "antipode"
Quote
for FormatDateTime in Delphi.

Best regards,
Ivan Babikov,
I-Software (www.i-software.narod.ru).