< previous page page_52 next page >

Page 52
struct DATE_INFO
    {
       int year;
       int month;
       int day;
    };
Most calendars use a system of year, month, and day for representing dates, so the DATE_INFO structure can be used for a surprisingly wide variety of timekeeping systems. Not all calendars employ this system, however, and DATE_INFO is either supplemented with, or supplanted by, other data structures in a few cases. These additional structures are discussed under the "Header Files" section of their respective calendars.
Although it is not a structure in the proper C sense of the word, I should also include the type double variable, since the SCDTL system uses it to carry the complete Julian Day number (JD#). The Julian Day number contains both date and time information and is one of the means of moving information about dates and times between parts of the SCDTL system.
3.2
Ranges
The variables in both structures are all type int and therefore represent signed integers. Because portability has always been an issue in C, it is necessary to accept some definitions about range, since the native integer length of different machines varies.
The SCDTL system elects to use the sizes defined in the C standard, section 5.2.4.2.1, given in the header file <limits.h>. Specifically, the minimum value for an object of type int is INT_MIN, with a value of -32767, and the maximum value for an object of type int is INT_MAX, with a value of +32767. In other words, type int is basically defined as a 16-bit integer with two's complement representation of values. The hardware-oriented reader will note that INT_MIN is not -32768.
The choice of type int for these variables is dictated by several considerations. First, many arithmetic operations in C work well with this length, and many common functions in C either return this type, accept it, or both. Second, the range is sufficient for the purpose. In the case of TIME_INFO, hours fall in the range 0 to 23, minutes in the range 0 to 59, and seconds in the range 0 to 59 (leap seconds notwithstanding). The type int is more than adequate to represent these values.
It may be argued in the case of TIME_INFO that use of type char would reduce the storage requirements for these variables. This observation is true, but the need to use these variables in functions that accept type int variables would necessitate constant conversions from one type to the other, with a concomitant waste of execution time and increased possibility for bugs. The only application where this argument might carry some weight is in situations requiring the storage of a very large numbers of

 
< previous page page_52 next page >