1
2 /*
3 * Copyright 1986 by Larry Campbell, 73 Concord Street, Maynard MA 01754 USA
4 * (maynard!campbell).
5 *
6 * John Chmielewski (tesla!jlc until 9/1/86, then rogue!jlc) assisted
7 * by doing the System V port and adding some nice features. Thanks!
8 */
9
10 /* Changes for the CM11A made by Daniel Suthers, dbs@tanj.com */
11
12 /*
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 *
26 */
27
28 #include <stdio.h>
29 #include <time.h>
30 #include "x10.h"
31 #include <unistd.h>
32 #ifdef SYSV
33 #include <sys/types.h>
34 #endif
35
36 #include <sys/param.h>
37 #ifdef BEFORE
38 #include <sys/filsys.h>
39 #endif
40 #include "x10.h"
41
42
43 extern void error();
44 extern int invalidate_for_cm10a();
45
46 extern int
47 Idays, Ijday, Ihours, Iminutes, Iseconds;
48
49 /* ARGSUSED */
50
c_date(int argc,char * argv[])51 int c_date( int argc, char *argv[] )
52 {
53 int today;
54 int expire;
55 struct tm *tp;
56 char RCSID[]= "@(#) $Id: date.c,v 1.8 2000/01/02 23:00:32 dbs Exp dbs $\n";
57 extern int usage(), get_status(), dowX2U();
58 extern struct tm *cm11a_to_legal();
59 time_t now;
60
61 if ( invalidate_for_cm10a() != 0 )
62 return 1;
63
64 display(RCSID);
65 if (argc != 2)
66 usage(E_2MANY);
67 time(&now);
68 tp = localtime(&now);
69
70 if( get_status() < 1 )
71 error(" No reponse from CM11A. Program exiting");
72
73 /* Translate CM11a clock data to Legal Time via */
74 /* info in X10 Record File (if it exists). */
75 tp = cm11a_to_legal( &Idays, &Ijday, &Ihours,
76 &Iminutes, &Iseconds, &expire );
77 expire = expire; /* Keep compiler from complaining */
78
79 today = dowX2U(Idays);
80 #ifndef POSIX
81 while (tp->tm_wday % 7 != today)
82 tp->tm_wday++, tp->tm_mday++;
83 #endif
84
85 #ifdef VENIX
86 (void) printf("%2d%02d%02d%02d%02d\n",
87 tp->tm_year % 100, tp->tm_mon + 1, tp->tm_mday, Ihours, Iminutes);
88 #else
89 (void) printf("%02d%02d%02d%02d%02d\n",
90 tp->tm_mon + 1, tp->tm_mday, Ihours, Iminutes, tp->tm_year % 100);
91 #endif
92 return(0);
93 }
94