dow.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* $selId: dow.c,v 2.0 1995/10/24 01:13:06 lees Exp $
  2. * Copyright 1993-1995, Scott E. Lee, all rights reserved.
  3. * Permission granted to use, copy, modify, distribute and sell so long as
  4. * the above copyright and this permission statement are retained in all
  5. * copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
  6. */
  7. /**************************************************************************
  8. *
  9. * These are the externally visible components of this file:
  10. *
  11. * int
  12. * DayOfWeek(
  13. * long int sdn);
  14. *
  15. * Convert a SDN to a day-of-week number (0 to 6). Where 0 stands for
  16. * Sunday, 1 for Monday, etc. and 6 stands for Saturday.
  17. *
  18. * char *DayNameShort[7];
  19. *
  20. * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
  21. * the abbreviated (three character) name of the day.
  22. *
  23. * char *DayNameLong[7];
  24. *
  25. * Convert a day-of-week number (0 to 6), as returned from DayOfWeek(), to
  26. * the name of the day.
  27. *
  28. **************************************************************************/
  29. #include "sdncal.h"
  30. int DayOfWeek(
  31. zend_long sdn)
  32. {
  33. int dow;
  34. dow = (sdn + 1) % 7;
  35. if (dow >= 0) {
  36. return (dow);
  37. } else {
  38. return (dow + 7);
  39. }
  40. }
  41. const char * const DayNameShort[7] =
  42. {
  43. "Sun",
  44. "Mon",
  45. "Tue",
  46. "Wed",
  47. "Thu",
  48. "Fri",
  49. "Sat"
  50. };
  51. const char * const DayNameLong[7] =
  52. {
  53. "Sunday",
  54. "Monday",
  55. "Tuesday",
  56. "Wednesday",
  57. "Thursday",
  58. "Friday",
  59. "Saturday"
  60. };