DAY - day library routine.

Description:

The TF source file LIBRARY/TF/DAY returns the day of the week which corresponds to a given date. The routine which calls LIBRARY/TF/DAY must set the following registers:

(YR)   - Year in which the date falls
(MON1) - Month
(DAY1) - Day

The program is called by the TF request

 .so LIBRARY/TF/DAY

The name of the weekday is returned in the register (ADAY). The number of the day (0=Sunday, 6=Saturday) is returned in register (DAYM). The values in registers (YR), (MON1) and (DAY1) are not changed. The registers (DAYC) and (DAYY) are used as scratch variables. The insertion character is set to "^" when the program terminates.

The program is valid for any date since the calendar was last changed in 1752. The program does not check that the date is valid, or even meaningful.

LIBRARY/TF/DAY can be used to determine the day of the week for a date which is only known in Julian form (day of the year). Set the year, set (MON1) to one, and set (DAY1) to the day number (see example (b)).

Examples:

(a) To determine the day of the week on which March 23, 1968 fell.

    .an (yr) 1968       (set the year)
    .an (mon1) 3        (set the month)
    .an (day1) 23       (set the day)
    .so library/tf/day  (call day routine)
    ^(aday)             (place result in text)

(b) To determine the day on which the 146th day of 1943 fell.

    .an (yr) 1943       (set the date)
    .an (mon1) 1
    .an (day1) 146
    .so library/tf/day
    ^(aday)             (place result in text)

(c) To insert the name of today's date.

    .ic ^               (set the insertion character)
    .an (yr) ^(year)    (set the date)
    .an (yr) +1900      (add the century to the year)
    .an (mon1) ^(mon)
    .an (day1) ^(day)
    .so library/tf/day
    ^(aday)             (place result in text)

The above is simply an example, since it is easier to use the predeclared register (%WDAY).

Notes:

If you want the names of the days entered in abbreviated form, foreign languages, etc., you can do so easily by obtaining a copy of the LIBRARY/TF/DAY file and changing the lines containing the names of the days.

Copyright © 1996, Thinkage Ltd.