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