
Year 2000 Examples
Intro
- Currently two digit representations of the year (e.g., 97 for 1997)
do not generally present a problem. However, in the year 2000, it may
cause serious computational problems.
- For example, a bookkeeping transaction may involve computing the time elapsed from
the purchase date to the current date. Suppose the purchase date was in 1995, then using 2 digit years, the number of years that have transpired is 97-95 = 2 years. However, suppose it is the year 2001 and again the purchase date is 1995.
Then, we have 01-95 = -96 years of elapsed time. However,
if modify our program so that two digit years after 2000 (and before 2100)
always represent years in the 21st century, then the problem is resolved, at
least during the 21st century.
The computation, then for the number of years between 95 and 01 is 2001-1995 =
6 years. This also requires that years before 2000 are unambiguously representative of the 20th century, as was done in this computation.
- If 95 is
replaced by 1995 and 01 by 2001 we're using 4 digit years, not
2 digit years and while this is the ultimate solution to the problem, this
would require programs converting to full year representation, not a trivial
task. Perhaps there's a way to maintain two digit year representation while
somehow getting four digit year accuracy? Whatever method is used,
it has to take care of another problem. How does a two digit scheme
take care of representation of two years like 1938 and 2038. In fact,
38 could represent any thirty eight year in any century.
- Again, the ultimate solution to the date problem is to always
use full four digit year representation. This means
converting programs from using 2 digit dates to the full 4 digit dates. This,
in most cases
presents an awesome undertaking. An alternative is to continue to use
2 digit dates but in such a way as to eliminate ambiguities as described
earlier.
- Suppose we define a two digit date as the number of years from some
reference date. Let's assume 1900. Then 20 is 20 years from 1900 and is the
year 1920. Fine. But what about 2020? If we pick 2000, then we've lost
years like 1997, since 97 would be 2097. Suppose we compromise and pick a
year in the 1900's. If we pick 1970, then 97 is 97-70= 27 years from the
reference year and represents the year 1970 + 27 = 1997 (or 70 + 1900 = 1997)
What about 20? If we agree that any year that is less than 70 represents
a year in the twenty-first century, then 20 is 2020. How many years can we
represent using this method. For computational accuracy, we need more than
years; we need seconds. Now the maximum number of seconds we can store in
a 32 bit integer corresponds to approximately 68 years. Thus, if we select
1970, we can represent the years 1970 - 2038. What about the year 1966?
Using the reference year, 1970, this would be negative time. More about this
below.
- Sun defines a program that is year 2000 compliant as follows:
A product certified as being y2000 compliant will not produce
errors in date data related to the year change from December 31,
1999 to January 1, 2000 and date representation by the product will be
accurate into the future, until the year 2037. The handling of leap
years will be done correctly.
The compliant product will define specific, non ambiguous representation
handling and interpretation of centuries represented by two digits if
such representation is allowed by the product.
- Why 2038? Suppose we pick 1970 as the start of a window of time in which
we will define compliance. How do we measure time beginning in 1970? More
specifically, how does Sun's system programs like getdate measure time?
They compute the number of seconds that have passed. And, if the starting
date is January 1, 1970, and the number of seconds is stored in a 32 bit
integer variable, the largest integer that can be stored is 2147483647, which
if divided by the number of seconds in a year, yields approximately 68
years and 1970 + 68 = 2038. If we also look at going back from 1970, we have
a total range going from December 13, 1901 until January 19, 2038. For a
more complete statement see The Interactive UNIX System and the Year 2000 .
- Now while the range
December 13, 1901 - January 19,2038
is representable using a 32 bit word, if 2 digit dates are to be used,
there remains the ambiguity of years like 1938 and 2038. So the result is
that
For the Interactive UNIX System, a program is deemed 'y2000 Compliant' if
it accurately and unambiguously accepts, stores, manipulates and displays
dates within the range 00:00:00 January 1 1970 to
03:14:07 January 19 2038, as detailed in this document.
(The statement goes on...)
To be deemed 'y2000 compliant' any use of two digit year must conform to the
following interpretation:
Values in the range 70-99 shall refer to the years
1970 to 1999.
Values in the range 00-38 shall refer to the years
2000 to 2038.
(and...)
Programs must not arbitrarily restrict date ranged to exclude
twenty-first century dates and must as a minimum accept dates
within the range 1970-2038.
(and also....!!!!....)
POSIX (IEEE 1003.1) states that the result of using negative values of
time_t is undefined:
If the year < 1970 or the value is negative, the
relationship is undefined.
Year 2000 Compliance
Summing up, we have the following:
According to Sun (see their Unix interactive web page), year 2000 compliance
requires that the years from January 1, 1970 to January 19, 2038 must be
representable by a year 2000 compliant program. This means that if 2 digit
year notation is used, the years 70-99 are 1970-1999 and the years 0-38
are the years 2000-2038.
Because a 32 bit integer is used to represent the time (in seconds) that
passes from the "epoch" 1970 when using 4 digit years, the years from
1901 thru 1970 and up to 2038 are representable. But for two digit years
like 55, there we expect that the program will fail. Is '55 1955, 2055?
In the examples below try various dates
in the year 2000 compliant range, 1970-2038 and try dates outside the
range.
Note that there the maximum
date via these examples was December 31, 2037. That is, January 1, 2038
failed. I need to talk to Sun about this. Also note that the four digit years
in the range 1902 - 1970 also work under Solaris 2.6, but not Solaris 2.5.
Some notes about using the Java program which calls the Date Class.......
(fill in later).
Program Y2000 and Y2000_usage
(explanation of the output from these programs)
Year 2000 Examples
Example 1: Calls to the procedure "getdate"
C routine "getdate" takes a string containing date information and
outputs values of day, month, and year (and ???0). The format of the
string is defined in a template file. In this example the template
file, "timetemplate.txt", is
%m
%A %B %d %Y, %H:%M:%S
%A
%B
%m/%d/%Y %I %p
%m/%d/%y %I %p
%d,%m,%Y %H:%M
at %A the %dst of %B in %Y
run job at %I %p,%B %dnd
%A den %d. %B %Y %H.%M Uhr
%m/%d/%y %T
%m/%d/%Y %T
where, for example,
%m/%d/%y %I %p
indicates the the form
month/day/<2-digit year> <12-hour clock time>
is acceptable. For example,
12/01/97 5 pm
and the same form above with %y replaced by %Y means that the full
4 digit year is acceptable. For example,
12/01/1997 4 am
The routine "getdate" is called in a C program called test5. To
run test5, enter date information that is of any of the examples
shown below:
10/12/1988 3 pm
10/12/88 5 am
Example 2: Using the Java Date Class
Here we've limited the input to the program that calls the
Date class to
a string input. Examples are:
01/01/1990
01/01/90
01/01/1988 00:10:22
01/01/88 04:00 pm
10/10/1971 01:01:44 pm
January 10 1998 10:10:33 pm
January 10 1998 22:10:33
Note that there you do not use a "," to separate the year and
the time in the last two examples.
-------
Example 3: Time Elapsed Between Two Dates Using the Date Class
As long as two dates are within the year 2000 compliant range, the time
elapsed between the two dates can be computed using either 4 digit dates
or 2 digit dates. Blah, blah, blah,...... (java vs c for in and out, 1900
on, before 1900, etc.)
-------
Programs that Process Dates Outside the Year 2000 Compliant Range
(things to do...references...e.g, y2000 book)