Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/packages/uucpbb/src/date822.c @ 1772:5ba8e711a1a3
source added
author | boisy |
---|---|
date | Fri, 01 Apr 2005 22:04:25 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1771:7f2e75d5b62d | 1772:5ba8e711a1a3 |
---|---|
1 /* date822.c This routine returns a date string in RFC-822 format. | |
2 Copyright (C) 1990, 1993 Rick Adams and Bob Billson | |
3 | |
4 This file is part of the OS-9 UUCP package, UUCPbb. | |
5 | |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software | |
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | |
20 The author of UUCPbb, Bob Billson, can be contacted at: | |
21 bob@kc2wz.bubble.org or uunet!kc2wz!bob or by snail mail: | |
22 21 Bates Way, Westfield, NJ 07090 | |
23 */ | |
24 | |
25 /* Returns a pointer to a character string containing the current date/time | |
26 in RFC-822 format. Requires Carl Kreider's CLIB.L or CLIBT.L to compile. | |
27 | |
28 ctime() format 'Mon Nov 21 11:31:54 1983\n\0' | |
29 | |
30 RFC822 format 'Mon, 21 Nov 1983 11:31:54 PST\0 | |
31 -or- 'Mon, 16 May 1988 02:13:10 -0700\0' | |
32 | |
33 The external variable 'tz' is defined in getparam.c and set in the | |
34 /DD/SYS/UUCP/Parameters file. */ | |
35 | |
36 #include "uucp.h" | |
37 #ifndef _OSK | |
38 #include <utime.h> | |
39 #else | |
40 #include <time.h> | |
41 #endif | |
42 | |
43 #define WORDSIZE 5 | |
44 | |
45 extern char tz[]; | |
46 static char RFCbuf[40]; /* RFC-822 formatted time string */ | |
47 | |
48 | |
49 char *date822() | |
50 { | |
51 static long save_t = 0L; | |
52 char date[26]; | |
53 register char *words[WORDSIZE]; | |
54 char *p, *adate; | |
55 long t; | |
56 | |
57 adate = RFCbuf; | |
58 | |
59 /* get the current time */ | |
60 time (&t); | |
61 | |
62 /* If the time different from when we were last called, update the ADATE | |
63 string and save the time in case we are immediately called again. If | |
64 the time is same, return the pointer to ADATE set from the previous | |
65 call. */ | |
66 | |
67 if (t != save_t) | |
68 { | |
69 save_t = t; | |
70 | |
71 /* convert the seconds to date/time format */ | |
72 strcpy (date, ctime (&t)); | |
73 p = strchr (date, '\n'); | |
74 *p = '\0'; | |
75 | |
76 /* separate the various elements */ | |
77 getargs (words, date, WORDSIZE); | |
78 | |
79 /* put them in the RFC-822 format */ | |
80 sprintf (adate, "%s, %s %s %s %s %s", | |
81 words[0], words[2], words[1], &words[4][2], | |
82 words[3], tz); | |
83 } | |
84 return (adate); | |
85 } |