Problem-[delphi7] Program date error handling on WIN7 computer

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.