Y2K problems abound, if you believe the consultants, at least. But sometimes a simple trick or two can mitigate a localized Y2K problem.
In many situations requiring Y2K remediation, the problem is not one of updating code; rather, it is one of updating the legacy data shared among applications. Changing a two-character year in this data, or a year represented in BCD (Binary Coded Decimal), is often very difficult. This is especially true when many other programs will be reading the same data files. Some of these programs may not actually read the date fields, but skip them, expecting them to be a certain size. In situations like this, there is a solution that enables you to avoid changing legacy data containing two-character or BCD year fields.
Suppose the legacy data uses a two-character year representation. You can add dates beyond 1999 to this data and yet maintain the two-character format, by using a letter followed by a number. Each letter would represent a decade. For example, A would represent the first decade, B the second, and so on. The year 2000 would be represented by A0 and the year 2035 would be represented by C5. The 20th century dates would remain the same and would not require any updating. Furthermore, only the programs that use the date would have to be changed. Any other program that uses other information in the file, but not the date, will not have to be changed. In fact, combining this scheme with the clever use of letters, you can easily represent a range of dates spanning over 2000 years. Figure 1 shows a function to convert an integer year to this two-character format. I also provide a function to convert the other way, and a test driver, on the CUJ ftp site. (See p. 3 for downloading instructions.)
Unfortunately, if the original data is in BCD, you can add only around 100 years to the life of the data. The BCD format represents one decimal digit in four bits. The hex bit pattern for 0 through 9 represents the digits '0' through '9' respectively. The hex bit patterns for 10 through 15 do not represent anything in BCD, so they're free for use. If the number represented by the first four bits is between 0 and 9, then the date falls within the 20th century. For numbers between 10 and 15, the date is in the 21st century [1]. To find the represented year when the first BCD digit is between 10 and 15, use the formula year = 2,000 + (x-10)*16 + y, where x is the first digit, and y is the second.
In this manner, the year 2000 would be represented by 10100000 (2000+(10-10)*16+0), and the year 2035 would be represented by 11000011 (2000+(12-10)*16+3). This scheme allows for dates from 2000 to 2095 without changing any of the legacy data. With a little more effort, the scheme could be changed to allow over 100 years, but either way, the solution acts only as a temporary band-aid. Its use will only postpone the inevitable.
If your data is hard to change without breaking many programs, consider one of the alternatives presented above. They might enable you to extend the life of existing programs and allow you the time to truly invest in upgrading your software and/or equipment.
Note
[1] This statement is conceptually intuitive, but slightly inaccurate. By convention, the 20th century spans the years 1901 through 2000, not 1900 through 1999, as would seem logical. Likewise, the 21st century spans the years 2001 through 2100. mb
Tanton Gibbs is a student at Harding University specializing in Programming Language and Automata Theory. His computer related interests involve small-scale compiler design and operating systems. He can be reached at thgibbs@harding.edu.