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