From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,47b877165af3dad0 X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,47b877165af3dad0 X-Google-Attributes: gid1164f8,public X-Google-Thread: ffc31,47b877165af3dad0 X-Google-Attributes: gidffc31,public X-Google-Thread: fdd80,47b877165af3dad0 X-Google-Attributes: gidfdd80,public From: Jerome Fine Subject: Re: Y2K Conversion of Date to Internal Format Date: 1998/08/17 Message-ID: <35D8AD45.458E8C95@idirect.com>#1/1 X-Deja-AN: 382104286 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-Trace: 17 Aug 1998 22:23:53 GMT, ts6-23t-18.idirect.com Organization: "Usenet User" MIME-Version: 1.0 Newsgroups: vmsnet.pdp-11,alt.sys.pdp11,comp.os.vms,comp.sys.dec I am in the process of converting some application programs which have been written in FORTRAN. The complete package uses an internal DATE value which starts on 26-Dec-1909 as 0 and increases for each day. The algorithm which is broken is: DATE = CONVRT ( MONTH, DAY, YEAR ) MONTH = MONTH - 2 IF ( MONTH .LE. 0 ) MONTH = MONTH + 12; YEAR = YEAR - 1 Q = YEAR / 100 R = YEAR - Q * 100 DATE = ( YEAR - 1910 ) * 365 + Q / 4 + R / 4 + ( MONTH + 1 ) * 28 + ( 26 * MONTH - 2 ) / 10 where all variables are 16 bit integers. Obviously the value overflows and becomes negative on 13-Sep-1999 which is exactly what is wanted. I have taken a few liberties with the FORTRAN code since I wanted to make the algorithm clear. The problem is that the algorithm BREAKS on 01-Mar-2000 at which point the DATE value reverts to the same value as for 06-Feb-2000 and 24 duplicates are created. There is also a routine which works in the opposite direction which just ignores the first set of duplicate days from 06-Feb-2000 to 29-Feb-2000. (A) Is anyone familiar with an algorithm which works to convert to the internal format and in the reverse direction? (B) The size is important since I MUST patch the application programs, NOT compile and link. I suspect that someone thought we should revert to the old Julian Calendar as opposed to the current Gregorian calendar when those 11? days were lost and give everyone a change to live 24 days a second time. I though a bit of humour might make the question a bit more interesting? I have added this portion of my request and modified the paragraph above in order to clarify things. First, although the algorithm will obviously be of a general nature, the actual implementation will be on a PDP-11 running a program under TSX-PLUS. The final language used to do the implementation will be coding in machine language since the changes will be PATCHES to an existing program. I do intend to use assembler (or MACRO) to do some of the testing. SO, no VMS (nor for that matter any other operating system dependent interactions) are allowed. This is, as expressed above, the necessity for a substitute algorithm for the current on which breaks on 06-Feb-2000. The inputs are: MONTH, DAY, YEAR The output is: Number of days since 26-Dec-1909. Note that on 12-Sep-1999, this value is 32767. On the next day, the value overflows (from a technical point of view) and becomes 32768. That value does not exist as far as FORTRAN IV is concerned since integers range from -32768 to +32767. That does not mean that the correct UNSIGNED value cannot be returned from a program written in machine language (MACRO) and used for subsequent calculations (although it is recognized that in some cases the FORTRAN generated instructions which use signed branches must be changed to unsigned branches - already done once when an expiry date of 31-Dec-1999 was required). Comments on the algorithm, although interesting, are not as appreciated as would a new algorithm which works. Incidentally, the reverse algorithm must also be produced since it is absolutely necessary to convert from the internal format to M/D/Y. Sincerely yours, Jerome Fine RT-11/TSX-PLUS User/Addict Year 2000 Solutions for Legacy RT-11 Applications (Sources not always required)