'=========================================================================== ' Subject: 2 DIGIT YEARS Date: 03-10-00 (20:19) ' Author: David O. Williams Code: QB, QBasic, PDS ' Origin: david.williams@ablelink.org Packet: DATETIME.ABC '=========================================================================== ' 2dig_yr David O. Williams 2000 ' E-mail: david.williams@ablelink.org ' Public Domain. No cost. No warranty. (But I think it is right!) ' Program is explained in PRINT statments below. DEFINT A-Z DECLARE FUNCTION LongYear (X) CLS PRINT "This program demonstrates present-centred two-digit year dating." PRINT PRINT "For many purposes, dates more than twenty or thirty years into" PRINT "either the past or the future are virtually never encountered." PRINT "It is therefore possible to use just two digits to represent" PRINT "the year, provided they are always interpreted in the context" PRINT "of the present date. For example, in the year 2000, the digits" PRINT "'75' would be interpreted as meaning the year 1975. But in" PRINT "2050, the same two digits would mean the year 2075." PRINT PRINT "To perform this interpretation, this program includes a function" PRINT "called LongYear. If the argument that is passed into this" PRINT "function is an integer between zero and 99, inclusive, so it" PRINT "can be a two-digit year, the LongYear function takes a value" PRINT "that is between (P-49) and (P+50), inclusive, where P is the" PRINT "*present* year, as shown by the computer's internal calendar," PRINT "and the right two digits of the function output are the same as the" PRINT "two digits of the input argument." PRINT PRINT "To demonstrate this function, the following loop allows you to" PRINT "input two-digit years, and will output them in four-digit format." PRINT "Enter any negative number to quit." PRINT DO INPUT "Year"; Y IF Y < 0 THEN EXIT DO PRINT LongYear(Y) LOOP CLS PRINT "In order to use this dating system in any program, just use" PRINT "two digits for the year-number in any date. However, before any" PRINT "calculations, comparisons, etc., are done that involve dates," PRINT "pass the two-digit values through the LongYear function, and" PRINT "do the calculations with the four-digit outputs of the function." PRINT END FUNCTION LongYear (X) Y = X IF Y < 100 AND Y >= 0 THEN Y = ((VAL(RIGHT$(DATE$, 4)) + 50 - Y) \ 100) * 100 + Y END IF LongYear = Y END FUNCTION