Delphi32 in the XXI century
It has been given in calling "bug from the year 2000" to a series of errors caused by the habit of the human beings of working with years of two figures. This that up to now produced some very bearable problems, with the century change they will make but pressing.
Delphi, as many programming languages, negotiates the date like the number of days lapsed from December of 1899, 28 that internally which, it is correct for the XXI, XXII and coming century, since for him the 31-12-1999, it will be the 36525, January 1 the 2000 will be the 36526, and so forth.
But inevitably it is necessary to take the dates to the screen to be shown them to the user and to pick up those that this it introduces us, that which makes indispensable the conversion of this numeric date to text format. Is it here where the problems begin since to convert the 36525 to date there is not possible error, but how does it convert Delphi32 the chain 01/01/99 to date? and the chain 01/01/01?.
They exist two groups of functions that they pick up text chains properly formateadas and they transform them into dates:
First Group: the functions whose programming reflects entirely inside Delphi. With StrToDate to the head pick up text chains and in case the year she/he has two figures they only consider that it belongs to the century of the current date of the system. This during many years, it has worked correctly but you preveén certain problems for the projects that in 1999 they have to begin the 12/07/00, since the computer will interpret that July of 1900, 12 must begin and likewise, in the year 2001, those born the 26/06/32, will have less 31 years (I mention these two examples because they have happened to me such and as the story in my last application).
Second group: the functions that you/they call to the library OLEAUT32.DLL of Windows. This library has been created to give support to the convert of dates of the languages of programming of Microsoft (Visual Basic). The main of the functions of this group is VarToDateTime that receives a fact of variable type, text chain for the case that occupies us, and it transforms it into date. OLEAUT32.DLL and, therefore, VarToDateTime, considers that anything didn't happen worthy of being mentioned before January of 1930, 1 and anything will pass after December 31 the 2029, since to this lapse of time it will adjust any date that has the year of two figures. This way, there won't be project possible to begin the 12/07/31 neither it would be possible that nobody had been born the 26/06/25. It is so sad that I refused to believe it until I read Microsoft Press article that you/they can find in (url) and I didn't have left more remedy than to surrender before the evidence.
The solution to this problem is easy: to always use dates with the year of four figures, but this
she/he has two inconveniences.
First, our suffering users that can not understand (neither me neither) that have to put four figures in the year to have changed century. After all never they believed that the 97 were the 1897, it is not this way easy to understand the confusion of the 00 with the 1900.
Second, the components of third that solve us the life to the programmers and that we usually capture for Internet. We don't know to that approaches have abided their developer (if it is that she/he has abided to some)
The solution that we propose you modifies the calls internally to the two groups of functions named previously, making possible that the conversion of dates in format text chain with year of two figures to format dates interns of Delphi32 it is adjusted to one year minimum parametrizable by the developer and amendable in time of execution. This year least one works from a property of a non visual component that is placed in the main Form of the application.
Once installed there is that compile the whole application, included components of third, in the event of having the code source. For we advise it to use the option Project|Build All of the main menu of Delphi.
To install this system we should decompress the package in a directory and to execute install.exe
This process substitutes the file of standard of Delphi, SysUtils.dcu for our own version, keeping the original file as SysUtils.old. Likewise, the installation process believes the file install.log that contains information for UnInstall.exe that will carry out the desinstalación process, in the case of being necessary. The installation processes and unistall require as indispensable condition that Delphi not this being executed.
In case the installation process failed, the user should not have bigger problem to substitute the file by hand SysUtils.dcu for which is included in the package, in the path of Delphi, habitually \Borland\Delphi32\LIB carrying out a copy of security of the original previously.
After executing install.exe, we should use the option Component|install of the main menu of Delphi to install the non visual component that negotiates the minimum year, to give a value to the property FirstYear and to reconstruct the whole application.