|
|
|
| Listing 5.9 | |
|
|
|
|
2 = Tue
3 = Wed
4 = Thu
5 = Fri
6 = Sat
NOTES:
1. Returns 'NULL' for indices outside the valid range of 0 6.
2. Use the function 'day_of_week_index ()' to obtain the index for a
given date in the Gregorian calendar system. Use the function
'day_of_week_index_JD0 ()' to obtain the same index for a date in
the Julian or Gregorian calendar systems.
3. If a buffer is designated to hold the value returned by this routine,
sufficient space must be allocated to hold the string returned. All
abbreviations are standardized to three characters in length, so the
allocated area must allow for 4 characters, including the terminating
null.
4. This routine assumes the standard SCDTL convention that Sunday is the
first day of the week (DOW).
5. The set of abbreviations is the most common one in English,
consisting of the first three letters of each DOW name.
*/
#include <stdio.h>
char *day_of_week_abbreviation (int day_index)
{
char *DOW_table [7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
if ((day_index < 0) || (day_index > 6))
return (NULL);
return (DOW_table [day_index]);
}
|
|
|
|
|
|
|
|