Board index » delphi » ShortDateFormat ahs no effect in CGI, ISAPI and Console apps
Ivan Babikov
![]() Delphi Developer |
Ivan Babikov
![]() Delphi Developer |
ShortDateFormat ahs no effect in CGI, ISAPI and Console apps2004-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). |
Dave Hackett
![]() Delphi Developer |
2004-08-06 09:01:10 PM
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 QuoteHello all, |
Ivan Babikov
![]() Delphi Developer |
2004-08-07 09:27:49 PM
Re:ShortDateFormat ahs no effect in CGI, ISAPI and Console apps
Hi Dave,
QuoteTry... Best regards, Ivan Babikov, I-Software (www.i-software.narod.ru). |
Dave Hackett
![]() Delphi Developer |
2004-08-14 10:57:42 AM
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
Quotefor FormatDateTime in Delphi. |