home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / mm / mm-ccmd-0.91-20031009.tar.gz / mm-ccmd-0.91-20031009.tar / work / ccmd / datime.h < prev    next >
C/C++ Source or Header  |  2002-02-20  |  6KB  |  162 lines

  1. /*
  2.  Copyright (c) 1986, 1990 by The Trustees of Columbia University in
  3.  the City of New York.  Permission is granted to any individual or
  4.  institution to use, copy, or redistribute this software so long as it
  5.  is not sold for profit, provided this copyright notice is retained.
  6.  
  7.  Author: Andrew Lowry
  8. */
  9. /* datime.h
  10. **
  11. ** Structures and symbols for manipulating times and timezones
  12. ** using the datime utilities.
  13. **/
  14.  
  15. #if CCMD_OS_MSDOS
  16. /* Fill in local timezone offset and code (if known) here */
  17. #define LCL_TZCODE TZ_UEST    /* USA Eastern time */
  18. #define LCL_TZOFF (5*60)    /* 5 hrs west of Greenwich */
  19. #endif
  20.  
  21. /*
  22. ** DATIME structures hold date and time information.  00:00:00 is considered
  23. ** the beginning of the day, not the end.
  24. **/
  25.  
  26. typedef struct DATIME {
  27.     short    _dtmon;        /* 0 = January, 11 = December */
  28.     short    _dtday;        /* 0 = first day of month */
  29.     int    _dtyr;
  30.     short    _dtdow;        /* day of week: 0 = Sunday, 6 = Saturday */
  31.     short    _dthr;        /* 0 to 23 */
  32.     short    _dtmin;
  33.     short    _dtsec;
  34.     int    _dttz;        /* time zone, # of mins west of Greenwich */
  35.                 /*  (this is the number of minutes to add */
  36.                 /*  in order to get GMT) */
  37.     int    _dttzc;        /* time zone code, one of TZ_XXX codes */
  38.                 /*  defined below, or -1 */
  39.     int    _dtdst;        /* additional minutes to shift due to */
  40.                 /*  daylight savings time (generally -60 */
  41.                 /*  when dst is in effect and 0 otherwise) */
  42. } datime;
  43.  
  44. /* Flags to control the time/date parse */
  45.  
  46. #define DTP_NTI 0x0001        /* do not parse time */
  47. #define DTP_N24 0x0002        /* no 24-hour time format allowed */
  48. #define DTP_NTM 0x0004        /* no AM/PM specifier allowed */
  49. #define DTP_NIS 0x0008        /* seconds may not be specified */
  50. #define DTP_AIS 0x0010        /* seconds must be specified after colon */
  51. #define DTP_NAC 0x0020        /* colon cannot appear between hrs and mins */
  52. #define DTP_AAC 0x0040        /* colon must appear between hrs and mins */
  53. #define DTP_AHM 0x0080        /* first # in time cannot be hrs & mins */
  54. #define DTP_AMS 0x0100        /* first # in time is both hrs and mins */
  55.                 /*  unless too any colons for this */
  56. #define DTP_NTZ 0x0200        /* no time zone allowed in input */
  57. #define DTP_NDA 0x0400        /* do not parse date */
  58. #define DTP_NNM 0x0800        /* month may not be numeric */
  59. #define DTP_SNM 0x1000        /* second of two date numbers is month */
  60. #define DTP_ERR 0x2000        /* do not swap month/day numbers if TAD_SNM */
  61.                 /*  setting implies range error */
  62. #define DTP_NDW 0x4000        /* do not allow day-of-week in input */
  63. #define DTP_NSP 0x8000        /* do not allow time to split date before */
  64.                 /*  year, as BSD's ctime call does (e.g. */
  65.                 /*  Saturday, 9 March 9:52am 1986 */
  66.  
  67.  
  68. /* DSTRULE
  69. **
  70. ** Describes rules for determining daylight savings times.  Each rule
  71. ** structure describes a time change that takes place at a given time
  72. ** on a given day of the year.  In most cases, the rules will be given
  73. ** in pairs, one turning on dst, and another turning it off.  When DST
  74. ** must be determined for a given date/time, the last change preceding
  75. ** that moment determines the dst adjustment that applies.
  76. **
  77. ** Each change rule can span several years indicating that the given
  78. ** change occurs in each of the spanned years.  The time at which
  79. ** a change occurs is specified in terms of the wall clock time (ie,
  80. ** including the preceding adjustment, if any).  The date of the change
  81. ** is given in terms of a day of the week and a julian date, meaning
  82. ** the last date on the given day-of-week that does NOT follow the
  83. ** given julian date (for example, last Sunday in April is the last
  84. ** Sunday not following April 30).  If no change occurs
  85. ** before a given date/time, a zero adjustment is to be used.
  86. **/
  87.  
  88. typedef struct DSTRULE {
  89.         int _dsyr1;                     /* first year in which change occurs */
  90.     int _dsyrn;            /* last year in which change occurs */
  91.     int _dsdow;            /* day of week of change (0-7 for */
  92.                     /*  Sun-Sat, -1 for date in _dsday) */
  93.     int _dsday;            /* julian day (assuming leap year) */
  94.                     /*  less than one week after change */
  95.                                     /*  Use 0 for Jan 1.  If >= 59 on a */
  96.                     /*  non-leap year, it is decremented */
  97.                     /*  by one before applying the rule */
  98.     int _dstim;            /* time of change (mins since 12M) */
  99. } dstrule;
  100.  
  101. typedef struct TZINF {            /* timezone information */
  102.     int _tzcode;            /* one of the TZ_XXX values */
  103.                     /*  defined below */
  104.     char *_tznam,*_tzdnm;        /* name, and name with dst */
  105.     int _tzoff;            /* minutes west of greenwich */
  106.     dstrule *_tzdst;        /* array of dst rules, terminated */
  107.                     /* by one for year zero */
  108.     int _tzdadj;            /* minutes to subtract during dst */
  109.     int _tzsth;            /* TRUE for southern hemisphere, */
  110.                     /* so the dst rules are reversed */
  111. } tzinf;
  112.  
  113.  
  114. /* Time zones that we know about */
  115.  
  116. #define    TZ_GMT    0            /* Greenwich Mean Time */
  117. #define    TZ_UAST    1            /* USA Atlantic */
  118. #define TZ_UEST    2            /* USA Eastern */
  119. #define TZ_UCST    3            /* USA Central */
  120. #define    TZ_UMST    4            /* USA Mountain */
  121. #define    TZ_UPST    5            /* USA PAcific */
  122. #define    TZ_UYST    6            /* USA Yukon */
  123. #define TZ_UHST    7            /* USA Alaska/Hawaii */
  124. #define    TZ_UBST    8            /* USA Bering */
  125. #define    TZ_EWET    9            /* EUROPE Western */
  126. #define    TZ_EMET    10            /* EUROPE Middle */
  127. #define    TZ_EEET    11            /* EUROPE Eastern */
  128. #define    TZ_AEST    12            /* AUSTRALIA Eastern */
  129. #define    TZ_ACST    13            /* AUSTRALIA Central */
  130. #define TZ_AWST    14            /* AUSTRALIA Western */
  131. #define TZ_JST 15            /* JAPAN */
  132.  
  133. /* Flags to be added to timezone ID's to indicate daylight savings time
  134. ** handling
  135. **/
  136.  
  137. #define TZ_DST    0x4000            /* dst was indicated */
  138. #define    TZ_STD    0x2000            /* standard time was indicated */
  139.  
  140.  
  141. /* Include the following flag in a timezone code passed to dttzinf to
  142. ** distinguish the code from a positive Greenwich offset.  (The flag is
  143. ** not examined if the passed value is negative, which can only be
  144. ** an offset */
  145.  
  146. #define TZ_CODE    0x1000
  147.  
  148. /* Routines that do not return ints */
  149.  
  150. tzinf *dttzinf();
  151.  
  152. /* Miscellaneous definitions */
  153.  
  154. #ifndef TRUE
  155. #define TRUE -1
  156. #define FALSE 0
  157. #endif
  158.  
  159. #ifndef NULL
  160. #define NULL 0
  161. #endif
  162.