|
|
|
|
|
|
|
There are two major formats for time. The first function [format_time_12 ()] assumes a 12-hour clock and uses the designators a.m. (ante meridian, or before noon) and p.m. (post meridian, or after noon) to distinguish between hours with duplicate numbers. The second format (Listing 5.6, page 92) assumes a 24-hour clock, which is more logical because the day consists of 24 hours. In this format, hours after noon simply continue the hour count, so that 1 p.m. in the 12-hour format is simply 13 in the 24-hour format. |
|
|
|
|
|
|
|
|
One does not encounter the jumble of unit order found with date formatting. The usual order is hoursminutesseconds. Seconds may be dropped. The separator character varies with country, with colon (:) and period (.) being common. |
|
|
|
|
|
|
|
|
Due to the popularity of the PC, I include in this section a set of functions for obtaining and setting the system time on the PC, as well as a set of functions for processing the file date and time, using the DOS convention for these variables. |
|
|
|
|
|
|
|
|
5.3.1
System Date and Time |
|
|
|
|
|
|
|
|
Functions get_system_date () and get_system_time () acquire (get) and functions set_system_date () and set_system_time () control (set) the values of both date and time for DOS machines. |
|
|
|
|
|
|
|
|
Four functions [date_to_DOS_date (), time_to_DOS_time (), DOS_date_to_date (), and DOS_time_to_time ()] convert SCDTL date and time structures to the equivalent DOS structures and back again. Note that there are certain constraints on the range available for the DOS variables. |
|
|
|
|
|
|
|
|
5.4
Julian Day Conversions |
|
|
|
|
|
|
|
|
Core functions convert Western calendar dates to their equivalent Julian Day numbers and vice versa: |
|
|
|
|
|
|
|
|
date_to_JD0 () returns the Julian Day number (JD#) for a given date in the Western (Julian and Gregorian) calendar (Listing 5.7, page 93). |
|
|
|
|
|
|
|
|
year_to_jan_0_JD0 () is a utility routine that returns the Julian Day number of "January 0" for a given year, which is 31 December of the preceding year. |
|
|
|
|
|