problem Phenomenon: I think we all have encountered in the XP on the date format without problems, after the WIN7.
problem Reason: because the new date format was added to the WIN7, but the old Delphi was not processed (if I was wrong, I hope the expert pointing).
Problem handling:
function StrToDateWin7 (datestr:string): Tdatetime;
var
T:tdatetime;
fs:tformatsettings;
begin
Try
Fs.shortdateformat: = ' yyyy-mm-dd ';
fs.dateseparator: = '-';
T: = Strtodate (Datestr, Fs);
except
T: = Strtodate (' 1899-01-01 ', Fs);
end;
Result: = T;
end;
PS:
Dateseparator:char
Date separator, used to separate month and day
Timeseparator:char
time separator, used to separate hours, minutes, seconds
shortdateformat:string
the definition of the short date format in the locale.
longdateformat:string
the definition of the long date format in the locale.
shorttimeformat:string
the definition of a short time format in a locale.
longtimeformat:string
the definition of a long time format in a locale.
timeamstring:string
string used to represent the morning
timepmstring:string
a string used to represent the afternoon
shortmonthnames:array[1..12] of String;
an array for the abbreviated name of the month, which is the string of the MMM identity that is displayed when using FormatDateTime
longmonthnames:array[1..12] of String;
An array that is used to fully represent the name of the month, which is the mmmm identity string that is displayed when using FormatDateTime
shortdaynames:array[1..7] of String;
An array that is used to indicate the name of the day of the week, which is the DDD identity string that is displayed when using FormatDateTime
longdaynames:array[1..7] of String;
An array that is used to fully represent the name of the day, which is the string of DDD identities that are displayed when using FormatDateTime
Twodigityearcenturywindow:word =;
The starting year when the two-bit year is used.
Problem-[delphi7] Program date error handling on WIN7 computer