caldate_mjd(3) caldate_mjd(3) NNAAMMEE caldate_mjd - manipulate calendar dates SSYYNNTTAAXX ##iinncclluuddee <> void ccaallddaattee__ffrroommmmjjdd(&_c_d,_d_a_y,_w_e_e_k_d_a_y,_y_e_a_r_d_a_y); long ccaallddaattee__mmjjdd(&_c_d); void ccaallddaattee__nnoorrmmaalliizzee(&_c_d); void ccaallddaattee__eeaasstteerr(&_c_d); struct caldate _c_d; long _d_a_y; int *_w_e_e_k_d_a_y; int *_y_e_a_r_d_a_y; BBAASSIICC CCOONNVVEERRSSIIOONNSS Every calendar date has a _m_o_d_i_f_i_e_d _J_u_l_i_a_n _d_a_y _n_u_m_b_e_r. The day number increases by 1 every day. Day number 0 is 17 November 1858. Day num- ber 51604 is 1 March 2000. ccaallddaattee__ffrroommmmjjdd puts into _c_d the date corresponding to the modified Julian day number _d_a_y. ccaallddaattee__ffrroommmmjjdd also computes the day of the week (0 through 6) and the day of the year (0 through 365). It stores the day of the week in **_w_e_e_k_d_a_y if _w_e_e_k_d_a_y is nonzero. It stores the day of the year in **_y_e_a_r_d_a_y if _y_e_a_r_d_a_y is nonzero. ccaallddaattee__mmjjdd returns the modified Julian day number corresponding to the date in _c_d. ccaallddaattee__mmjjdd accepts days outside the range 1 to 31, referring to days before the beginning or after the end of the month. It also accepts months outside the range 1 to 12, referring to months before the begin- ning or after the end of the year. ccaallddaattee__nnoorrmmaalliizzee calls ccaallddaattee__ffrroommmmjjdd with the result of ccaallddaattee__mmjjdd. This means that it accepts out-of-range months and out-of-range days in _c_d, and puts a valid calendar date back into _c_d. OOTTHHEERR FFUUNNCCTTIIOONNSS ccaallddaattee__eeaasstteerr reads the year from _c_d and then changes _c_d to the date of Easter in the same year. LLIIMMIITTAATTIIOONNSS The ccaallddaattee routines currently support the Gregorian calendar, which was defined in 1582 and adopted at different times in different coun- tries. For earlier dates the ccaallddaattee routines work with ``virtual Gre- gorian,'' defined mathematically by the 400-year Gregorian cycle for years before 1582. The Julian calendar is not supported. The Gregorian calendar will be replaced by a new calendar within a few thousand years. The ccaallddaattee__ffrroommmmjjdd and ccaallddaattee__mmjjdd routines will be upgraded accordingly. The current ccaallddaattee__ffrroommmmjjdd and ccaallddaattee__mmjjdd rou- tines are not useful for dates far in the future. Day numbers will overflow a 32-bit lloonngg sometime after the year 5000000; all systems should upgrade to 64-bit lloonnggs before then. ccaall-- ddaattee__mmjjdd does not check for overflow. SSEEEE AALLSSOO caldate(3) caldate_mjd(3)