Abstract:
A date data processor verifies whether an inputted date data exists or not. Inputted date data is stored in an input register which is composed of three sections according to month, day and year. A first calculating unit calculates the days difference between the inputted date data and a reference date, and the results are temporarily stored. A second calculating unit then performs an inverse calculating to arrive at a date based on the previously calculated days difference. The resulting date is compared with the inputted date to complete the verification.

Description:
BACKGROUND OF THE INVENTION 
     The invention relates to a data processor for processing the data relating to date such as day, month and year and, more particularly, to an electronic desk-top calculator capable of processing such date data. 
     A small-sized calculator for processing the date data such as a desk-top calculator has been presented for practical use, in which calculator the input date data inputted is processed on the basis of a difference of the inputted date from a reference date. When an unreal date, for example, the 13th month 1, 1978 or Feb. 29, 1978, is erroneously applied to the calculator, the calculator processes the data without checking such erroneous date data, and presents an erroneous result. One of the conventional calculators, which is directed to solve such a problem, successively compares day, month and year of the input data with the correct data stored in the calculator, for the purpose of checking whether the input date data exists or not. Specifically, whether the data relating to year is calculable or not in the calculator is first checked. Whether the data relating to month is within the range 1 to 12 or not is then checked. Finally, the data relating to day is checked on the basis of the results of the checks of year and month. In checking the day data, it is necessary to check whether the year data is a leap year or not to determine if February has the 29th day or the 28th day as the final day. Therefore, the conventional calculator must store a large amount of data for the comparing reference. This fact encumbers the improvement of the manufacturing cost and size of the data processor such as a desk-top calculator. 
     SUMMARY OF THE INVENTION 
     Accordingly, an object of the invention is to provide a date data processor capable of judging whether input date data to be processed involves a real date or not. 
     Another object of the invention is to provide a small-sized electronic desk-top calculator with a checking function of the date data inputted. 
     The present invention may be briefly summarized as involving a data processor comprising: first memory means for storing a date to be operated and processed; means for calculating a difference of days from a reference date to the date to be operated; means for producing an inversely calculated date by inversely-calculating a date by using the days difference; second memory means for storing the inversely calculated date; and means for comparing the contents of the first memory means with the contents of the second memory means. 
     In operation, a keyed input date is converted to numerical date data and stored in an input register which is composed of three sections according to month, day and year. The inputted date data is then set into a second register also composed of three sections according to month, day and year. A first calculating unit then calculates the days difference between the date data stored in the second register and a reference date. In the specific example to be described, the reference date is Mar. 1, 1900. The days difference is calculated by first computing the difference in years, months and days and storing the results in the second register in the corresponding sections. The difference in years is multiplied by 365.25 and the difference in months is multiplied by 30.6, and the integer parts of these two products are summed with the difference in days. The thus calculated days difference is temporarily stored in a third register. A second calculating unit then inversely calculates the date from the days difference stored in the third register. First, the year is computed by dividing the contents of the third register by 365.25 and storing the integer part of the quotient in the corresponding section of the second register, the remainder being stored in the third register. Next, the contents of the third register are divided by 30.6, the integer part of the quotient being stored in the months&#39; section of the second register and the remainder being stored in the third register. The contents of the third register are then rounded off and stored in the days&#39; section of the second register. The contents of the second register are then compared in an Exclusive OR gate with the contents of the input register to verify whether the inputted date data exists. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     Other objects and features of the invention will be apparent from the following description taken in connection with the accompanying drawings, in which: 
     FIG. 1 shows a block diagram of an embodiment of a date data processor according to the invention; 
     FIG. 2 shows a flow chart useful in explaining the operation of the date data processor shown in FIG. 1; and 
     FIG. 3 shows a flow chart for illustrating an inverse-calculation of a date in the embodiment of the invention. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     Referring now to the drawings and, specifically, to FIG. 1, there is depicted a block diagram of a date data processor incorporating a preferred embodiment according to the invention. The date data applied by means of a key group 1 is converted into numerical data representing the input date by a key input unit 2 and the numerical data converted is then loaded into a date storage register 4 by way of an AND gate 3 in response to a signal 14a. The register 4 includes a memory area X D  for storing &#34;day&#34;, a memory area X M  for storing &#34;month&#34; and a memory area X Y  for storing &#34;year&#34;. These memory areas are defined by a digit timing signal. To the other input of the AND gate 3 is applied a control signal 14a from an operation control signal generator 14 which sequentially produces various kinds of necessary signals for operation of the system. The output signal from the date storing register 4 is applied to the unit 10 for calculating the number of days, through a two-input AND gate 5 supplied at one input with a control signal 14b. The days calculating unit 10 is controlled by a control signal 14e and operatively associated with W register 20 and Z register 21. The W register includes a memory areas W Y , W D  and W M . A memory circuit 6 for storing a constant 365.25 and a memory circuit 7 for storing a constant 30.6, which may be registers, are associated with the days calculating unit through AND gate 8 having one input to which signal 14c is applied and AND gate 9 having one input to which signal 14d is applied, respectively. Included in the days calculating unit 10 are arithmetic means such as an adder, gating means for interfacing W register 20 and Z register 21, and related gates for executing given arithmetic operations (not shown). The days calculating unit 10 calculates the number of days from the input date which is stored in the date storing register 4 to a given reference date, for example, Mar. 1, 1900, said number being referred to as the days difference or the difference of days. 
     As an example, it will be assumed that the system is operating to calculate the difference of days in the case where the input date data is in a range from Mar. 1, 1900, to Feb. 28, 2100, and the reference date is Mar. 1, 1900. Reference is made to the flow chart of FIG. 2 which illustrates the operation of the calculation. At a first step (1), the contents of register 4 are loaded into the W register 20 associated with the days calculating unit 10 in synchronism with the control signal 14a. At this time, the contents of register 4 are not changed. More specifically, the contents of the memory areas X M , X D  and X Y  are loaded into the memory areas W M , W D  and W Y , respectively, thereby storing information relating to &#34;month&#34;, &#34;day&#34; and &#34;year&#34; in the areas W M , W D  and W Y , respectively. Then, at a second step (2), a determination is made as to whether the contents of the memory W M , i.e, &#34;month&#34; are larger than 3 or not. If it is equal to or larger than 3, the control operation advances to step (3) and the result of subtraction of 3 from the contents of the memory area W M  are reloaded into the memory area W M  . If the contents are smaller than 3, the operation advances to step (5) where 9 is added to the contents of W M , which sum is reloaded into the W M . Thus, the contents of W M  obtained by steps (3) or (5) is the difference between the month of the input date and the month of the reference date. In this example, the reference month is March and therefore the number of months from March is the month difference. Accordingly, in the case of January and February, 10 and 11 months are the difference months from the reference month, i.e, March. This is obtained as shown in step (5). In this case, the operation proceeds to step (6) where the results of the subtraction of 1901 from the contents in the memory area W Y  i.e &#34;year&#34; is reloaded into the W Y . January and February are considered as the months in the previous year with respect to the reference month, i.e. March. For this reason, &#34;1&#34;  must be subtracted from the difference between the year of the input date and the year of the reference date, for purpose of correction. Accordingly, the contents of the W Y  loaded in step (6) are the difference years between the year of the inputted date data and the year of the reference date. While in the case of step (3), the year difference is the result of subtraction of the reference year 1900 from the year of the input date and is written into the area W Y , as shown in step (4). In step (6), if the result is negative, the date data is not calculable in the date data processor, resulting in an error. Then, in step (7) the difference in days between the input date data and the reference date is calculated in response to signal 14e, by using the difference year stored in the memory area W Y , the difference month stored in the memory area W M , and the day stored in the area W D . For this purpose, a constant 365.25 stored in the memory circuit 6, corresponding to the average number of days of one year including a leap year, is introduced into the days calculating unit 10 via the gate 8 in synchronism with the control signal 14c. Also, a constant 30.6 stored in the memory circuit 7 is introduced from the register 7 into the unit 10 via the gate 9 in synchronism with the control signal 14d. The sum of the integer part of the product of the constant 365.25 and the year difference loaded into the memory area W Y  at steps (4) or (6), the integer part of the product of the constant 30.6 and the month difference loaded into the memory area W M  at steps (3) or (5), and the day of the memory area W D , is calculated, which sum is the day difference between the input date data and the reference data. The day difference i.e, the sum is loaded into the memory circuit Z. Then, in step (8) the contents of the memory circuit Z are checked to determine whether the contents are larger than the constant 72989. When the contents of the memory Z are larger than the constant, the input data is beyond Feb. 28, 2100, and is uncalculable, resulting in an error. In this manner, the days calculating unit 10 calculates the day difference between the input date and the reference date and stores it therein. 
     Next, the inverse calculation will be described with reference to FIGS. 1 and 3. The inverse-calculation unit 13 is operatively associated with W register 20, Z register 21 and flip-flop 22 and includes arithmetic means (e.g. an adder), gating means for interfacing W register 20 and Z register 21. In response to signal 14h, the unit 13 is enabled. At a step (10), &#34;0&#34; is loaded into the memory areas W Y , W M , and W D  in W register 20 to set them to initial states. In a step (11), the contents of the register 6, i.e. the average days of one year, 365.25, is introduced into the inverse-calculation unit 13 via AND gate 11 in synchronism with the control signal 14f. In the unit 13, the contents of Z register 21 which is the number of days is divided by the average days 365.25 introduced. The integer part of the quotient as a result of the division is loaded as an inversely-calculated year difference in the memory area W Y . In a step (12), the days difference corresponding to the year difference, that is, the product of the contents of the area W Y  and 365.25, is subtracted from the contents of Z register 21. Then, the subtraction is rounded to one decimal place by adding 0.9 thereto which corresponds to the sum of the difference days relating to the difference months and days per se. The integer of a value obtained through this operation, that is the rounded subtraction, is loaded into Z register 21. Then, at step (13), the flip-flop 22 is set. The flip-flop 22 is used for judging whether the inversely-calculated &#34;month&#34; is January or February in the proceeding step. Then, in step (14) the contents of Z register 21 are checked to determine whether it is &#34;0&#34;. If it is &#34;0&#34;, the date is February 29 of a leap year. In this case, at step (15) 366 is loaded into Z register 21, and at step (16) the flip-flop 22 is reset. In step (17), the contents 30.6 of the register 7 are loaded into the date inverse-calculation unit 13 via AND gate 12 in synchronism with control signal 14g. In the unit 13, the constant 30.6 is used to divide the contents of Z register 21. The integer of the quotient of the division is loaded as an inversely-calculated month difference in the memory area W M . In step (18), the product of the quotient in step (17), i.e. the contents of the memory area W M  and the constant 30.6 are subtracted from the contents of Z register 21. The difference as a result of the subtraction is loaded into Z register 21. The integral part of a value obtained by rounding the figures of the surplus below the decimal point by adding 0.5 thereto corresponds to the number of days per se. When the surplus has no integer part, that is the content of Z is below 0.6, the following correction is executed. Specifically, in step (19), the contents of Z register 21 is checked to determine whether they are larger than 0.6. When the contents are below 0.6 in which the surplus has no integer part, the operation proceeds to the next step (20) where 31 is loaded into Z register 21 and, in step (21), 1 is subtracted from the contents of the memory area W M  and the difference obtained is reloaded into the memory area W M . Then, the operation advances to step (22) where 0.5 is added to the contents of Z register 21 to round the contents at one decimal place. And the integer part of the rounded result is loaded into the memory area W D  as an inversly-calculated date. 
     Then, the inversely-calculated month difference thus obtained, i.e. the contents of the memory area W M , is the difference counted from March. Accordingly, when this value is within 0 to 9, the inversely-calculated month can be obtained by adding 3 to the value. Namely, in step (23), the contents of the memory area W M  are checked to determine if they are larger than 9 or not. If they are equal to or less than 9, the operation advances to step (25), where 3 is added to the contents of W M  and the result of the addition is reloaded into W M  as the inversely-calculated month. Then in step (26) the flip-flop 22 is reset since the inversely-calculated month is within a range from March to December. On the other hand, when the contents of W M  is larger than 9 in step (23), it corresponds to January or February. Accordingly, in step (24), 9 is subtracted from the contents of W M  and the result of this subtraction is loaded into the memory area W M  as the inversely-calculated month. In the case where the month difference, i.e. the contents of the memory area W M  in step (23), is 10 or 11 months, it corresponds to January or February. In this case, it is required to compensate the correction mentioned relating to the days calculating unit 10, that is, adding &#34;1&#34; to the year difference stored in the memory area W Y . Accordingly, in step (27) the state of the flip-flop 22 is checked. If the flip-flop 22 is set, i.e. &#34;1&#34;, the operation advances to a step (29) where 1 is added to the contents W Y , i.e. the year difference. A value obtained by adding 1900 to the year difference is the dominical year inversely-calculated. The result of this is again loaded into the memory area W Y . On the other hand, unless the flip-flop 22 is &#34;1&#34;, step (28) is performed. In this step, 1900 is added to the contents of W Y , i.e. the year difference and the sum thereof is loaded as the dominical year inversely-calculated. In this way, the dominical year, the months and the day, which are inversely calculated, are stored in the memory areas W Y , W M  and W D  in W register 20, respectively. The date thus calculated is compared with the input date data stored in X register 4 in step (30). When these are coincident, the input date really exists, and when these are not coincident each other, the input data is unreal. 
     The date thus inversely-calculated is transferred to the register 16 through an AND gate 15 in response to a control signal 14i. The outputs of the registers 4 and 16 are applied to an exclusive OR gate 17, the output of which is coupled to the reset input terminal of the R-S flip-flop 18. The comparison of the contents of the register 4, that is the date data inputted by the key operation, with the date data inversely-calculated and stored in the register 16, is carried out in the following maner. 
     Firstly, a control signal 14j is generated as a set signal for the R-S flip-flop 18 at an arbitrary time before the generation of the signal 14i, and the output Q of the R-S flip-flop 18 is set to logic &#34;1&#34;. Under this condition, the exclusive OR gate 17 produces logic &#34;1&#34; and at this time the R-S flip-flop 18 is reset to produce logic &#34;0&#34; at the output Q and &#34;1&#34; at the output Q. This state corresponds to a state that the contents of the registers 4 and 16 are not coincident with each other. While logic &#34;0&#34; appears at the output of the exclusive OR gate 17 and is applied to the reset terminal of the R-S flip-flop 18, the flip-flop 18 produces logic &#34;1&#34; at the output Q, and continues this output state. This state indicates that the contents of both the registers 4 and 16 are coincident each other. Then, the output Q of the R-S flip-flop 18 is applied to the control signal generator 14 to inform it of that the input date data really exists or not. Upon receipt of the output Q, the control signal generator 14 performs a given operation. If the date data processor is provided with a display device for displaying a special indication and when the output Q of the R-S flip-flop 18 is logic &#34;0&#34;, an operator visually recognizes that the input date data is erronous. To this end, logic &#34;1&#34;, for example, of the output Q may be used in place of the &#34;0&#34; of the output Q. 
     Let us consider two cases; one for the 13th month 1, 1977, stored in the register 4, the other for Jan. 1, 1978, stored therein. In the case of the 13th month 1, 1977, a difference of days is calculated by the days calculating unit 10 and is 28431. This days difference is applied to the date inverse-calculation unit 13 where it is subjected to the inverse-calculation to obtain Jan. 1, 1978, which in turn is stored in the register 16. The combination of the exclusive OR gate 17 and the R-S flip-flop 18 compares the 13th month 1, 1977, in the register 4 with Jan. 1, 1978. In this case, the output of the R-S flip-flop 18 is logic &#34;0&#34; indicating that the contents in the register 4 are unreal. The controller 14 displays this by the display means and stops the succeeding operation. While in the case of Jan. 1, 1978, the register 16 also stores Jan. 1, 1978 inversely calculated. The output of the R-S flip-flip 18 is logic &#34;1&#34; so that it is judged that the contents of the register 4 really exist. In this case, the controller 14 operates so that the result of this is not displayed and the succeeding operation is performed. 
     As described above, according to the invention, in a small-sized computer executing the operation relating to the date data, it is possible to judge the data which is unreal. Accordingly, when an input date is erronous, the succeeding calculation which is nonsense is eliminated. In the above-mentioned embodiment, the reference date is Mar. 1, 1900, but it is not limited to that. The calculating method for obtaining the number of days and the inverse calculation method may also be changed in accordance with the reference date selected. In the present invention, the register 16 can be eliminated by directly utilizing W register 20 for comparison with the contents of X register 4 where the function of the gate 15 is included in the unit 13. Also in the present invention ramdom access memory circuits may be used in place of registers 4, 16, 20 and 21.