5d99cf5a0fc6aed84b97b4e3b774d0cbd1eb34db
[mmh] / h / tws.h
1
2 /*
3  * tws.h
4  */
5
6 /* If the following is #defined, a timezone given as a numeric-only offset will
7    be treated specially if it's in a zone that observes Daylight Saving Time.
8    For instance, during DST, a Date: like "Mon, 24 Jul 2000 12:31:44 -0700" will
9    be printed as "Mon, 24 Jul 2000 12:31:44 PDT".  Without the code activated by
10    the following #define, that'd be incorrectly printed as "...MST". */
11 #define ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST 1
12
13 struct tws {
14     int tw_sec;         /* seconds after the minute - [0, 61] */
15     int tw_min;         /* minutes after the hour - [0, 59]   */
16     int tw_hour;        /* hour since midnight - [0, 23]      */
17     int tw_mday;        /* day of the month - [1, 31]         */
18     int tw_mon;         /* months since January - [0, 11]     */
19     int tw_year;        /* 4 digit year (ie, 1997)            */
20     int tw_wday;        /* days since Sunday - [0, 6]         */
21     int tw_yday;        /* days since January 1 - [0, 365]    */
22     int tw_zone;
23     time_t tw_clock;    /* if != 0, corresponding calendar value */
24     int tw_flags;
25 };
26
27 #define TW_NULL  0x0000
28
29 #define TW_SDAY  0x0003 /* how day-of-week was determined */
30 #define TW_SNIL  0x0000 /*   not given                    */
31 #define TW_SEXP  0x0001 /*   explicitly given             */
32 #define TW_SIMP  0x0002 /*   implicitly given             */
33
34 #define TW_SZONE 0x0004 /* how timezone was determined    */
35 #define TW_SZNIL 0x0000 /*   not given                    */
36 #define TW_SZEXP 0x0004 /*   explicitly given             */
37
38 #define TW_DST   0x0010 /* daylight savings time          */
39 #define TW_ZONE  0x0020 /* use numeric timezones only     */
40
41 #define TW_SUCC  0x0040 /* whether parsing was successful */
42 #define TW_YES   0x0040 /*   yes, found                   */
43 #define TW_NO    0x0000 /*   no, not found                */
44
45 #define dtwszone(tw) dtimezone (tw->tw_zone, tw->tw_flags)
46
47 extern char *tw_dotw[];
48 extern char *tw_ldotw[];
49 extern char *tw_moty[];
50
51 /*
52  * prototypes
53  */
54 char *dtime (time_t *, int);
55 char *dtimenow (int);
56 char *dctime (struct tws *);
57 struct tws *dlocaltimenow (void);
58 struct tws *dlocaltime (time_t *);
59 struct tws *dgmtime (time_t *);
60 char *dasctime (struct tws *, int);
61 char *dtimezone (int, int);
62 void twscopy (struct tws *, struct tws *);
63 int twsort (struct tws *, struct tws *);
64 time_t dmktime (struct tws *);
65 void set_dotw (struct tws *);
66
67 struct tws *dparsetime (char *);
68