< previous page page_83 next page >

Page 83
5.6.4.5
Time and Long Integer
The fifth and last set of compression routines presented converts time of day to and from type long variables.
long_to_time () unpacks the values in a single type long time stamp variable into a TIME_INFO structure.
time_to_long () stores the values in a TIME_INFO structure into a single type long time stamp variable.
5.6.5
Exploiting Aspects of the Perpetual Calendar
The Western calendar contains regularities that may be exploited for certain purposes.
5.6.5.1
Concepts
Although the Western calendar at first seems to present a bewildering variety of possible structures, the situation is actually simple. The first of the year must fall on one of the seven days of the week. The day of the week on which every day of the year falls is completely determined once this datum has been determined, except for one additional wrinkle. That wrinkle is leap year. When a leap year occurs, the sequence of days is thrown off by one day after 28 February. But again, the day of the week for all following days of the year is completely determined, once this datum is known.
There are, therefore, fourteen types of year. Seven of them are common years and depend upon the day of the week on which the first of January falls. The remaining seven are leap years and also depend upon the day of the week for the first of January, but differ for dates after 28 February. These types of year appear in almanacs as ''perpetual calendars." The Jewish calendar also has fourteen different types of year, but this resemblance is entirely superficial, since the structures and reasons for the types are completely different. This is valuable information, because once the year type is known, the complete structure of the calendar for that year is known. The year type is not difficult to determine (Listing 5.11, page 99).
The closely related concept of "dominical letter" was used to organize the ecclesiastical calendar for many centuries. Note that the Julian calendar had a regular 28-year cycle of year types, whereas the Gregorian calendar has a much longer cycle, owing to the additional complexity of the leap year rule. There are, in fact, a large number of different cycles in the Western calendar.
You may also extend the same concept of type to months [month_type ()].
5.6.6
Time Conversions
In the Western timekeeping system, which has become global for virtually all scientific and commercial purposes and nearly universal for most civic uses, essentially two variants are of sufficient concern to warrant separate treatment. The first of these

 
< previous page page_83 next page >