home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / SCALDATE.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  3KB  |  84 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. ** scalar date routines    --    public domain by Ray Gardner
  5. ** Numerically, these will work over the range 1/01/01 thru 14699/12/31.
  6. ** Practically, these only work from the beginning of the Gregorian
  7. ** calendar thru 14699/12/31.  The Gregorian calendar took effect in
  8. ** much of Europe in about 1582, some parts of Germany in about 1700, in
  9. ** England and the colonies in about 1752ff, and in Russia in 1918.
  10. */
  11.  
  12. #ifndef SCALDATE__H
  13. #define SCALDATE__H
  14.  
  15. #include "sniptype.h"
  16.  
  17. /*
  18. **  Define ISO_CAL to be 1 for ISO (Mon-Sun) calendars
  19. **
  20. **  ISO defines the first week with 4 or more days in it to be week #1.
  21. */
  22.  
  23. #ifndef ISO_CAL
  24.  #define ISO_CAL 0
  25. #endif
  26.  
  27. #if (ISO_CAL != 0 && ISO_CAL != 1)
  28.  #error ISO_CAL must be set to either 0 or 1
  29. #endif
  30.  
  31. #if ISO_CAL
  32.  enum DOW_T {DOW_IGNORE = -1,
  33.        MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY};
  34. #else
  35.  enum DOW_T {DOW_IGNORE = -1,
  36.        SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY};
  37. #endif
  38.  
  39. /*
  40. **  Daylight savings time rules.
  41. **
  42. **  Rules include a month, date, and day. If the day is DOW_IGNORE, DST will
  43. **  start on the month and date specified. If a day is specified (the
  44. **  interpretation of the day parameter is subject to the value of ISO_CAL),
  45. **  DST will start on the first such day following (or equal to) the specified
  46. **  date, or stop on the first such day preceding (or equal to) the specified
  47. **  date.
  48. **
  49. **  The defaults defined for the U.S. mean that DST will begin on the first
  50. **  Sunday after (or on) April 1 and end on the last Sunday preceding (or on)
  51. **  October 31.
  52. */
  53.  
  54. extern unsigned   DST_start_mo;
  55. extern unsigned   DST_start_dt;
  56. extern enum DOW_T DST_start_dy;
  57.  
  58. extern unsigned   DST_stop_mo;
  59. extern unsigned   DST_stop_dt;
  60. extern enum DOW_T DST_stop_dy;
  61.  
  62. int  isleap (unsigned yr);
  63. long ymd_to_scalar (unsigned yr, unsigned mo, unsigned day);
  64. void scalar_to_ymd (long scalar, unsigned *yr, unsigned *mo, unsigned *day);
  65. int  daynum(int year, int month, int day);
  66. int  weeknum(int year, int month, int day);
  67.  
  68. Boolean_T valiDate(unsigned yr, unsigned mo, unsigned day);
  69.  
  70. unsigned dow(unsigned yr, unsigned mo, unsigned day);
  71. unsigned DOW(unsigned y, unsigned m, unsigned d);
  72.  
  73. long today(void);
  74.  
  75. extern char *MoonPhaseText[8];
  76.  
  77. unsigned moonphase(unsigned yr, unsigned mo, unsigned dy);
  78.  
  79. int getfdate (int handle, long *date);
  80. int getdatef (char *fname, long *date);
  81.  
  82.  
  83. #endif /* SCALDATE__H */
  84.