xref: /titanic_52/usr/src/cmd/cal/cal.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include <langinfo.h>
34*7c478bd9Sstevel@tonic-gate #include <locale.h>
35*7c478bd9Sstevel@tonic-gate #include <nl_types.h>
36*7c478bd9Sstevel@tonic-gate #include <stdio.h>
37*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
38*7c478bd9Sstevel@tonic-gate #include <time.h>
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate static int number(char *);
41*7c478bd9Sstevel@tonic-gate static int jan1(const int);
42*7c478bd9Sstevel@tonic-gate static void badmonth(void);
43*7c478bd9Sstevel@tonic-gate static void badyear(void);
44*7c478bd9Sstevel@tonic-gate static void usage(void);
45*7c478bd9Sstevel@tonic-gate static void cal(const int, const int, char *, const int);
46*7c478bd9Sstevel@tonic-gate static void load_months(void);
47*7c478bd9Sstevel@tonic-gate static void pstr(char *, const int);
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate #define	DAYW	" S  M Tu  W Th  F  S"
50*7c478bd9Sstevel@tonic-gate #define	TITLE	"   %s %u\n"
51*7c478bd9Sstevel@tonic-gate #define	YEAR	"\n\n\n\t\t\t\t%u\n\n"
52*7c478bd9Sstevel@tonic-gate #define	MONTH	"\t%4.3s\t\t\t%.3s\t\t%10.3s\n"
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate static char *months[] = {
55*7c478bd9Sstevel@tonic-gate 	"January", "February", "March", "April",
56*7c478bd9Sstevel@tonic-gate 	"May", "June", "July", "August",
57*7c478bd9Sstevel@tonic-gate 	"September", "October", "November", "December",
58*7c478bd9Sstevel@tonic-gate };
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate static char *short_months[] = {
61*7c478bd9Sstevel@tonic-gate 	"Jan", "Feb", "Mar", "Apr",
62*7c478bd9Sstevel@tonic-gate 	"May", "Jun", "Jul", "Aug",
63*7c478bd9Sstevel@tonic-gate 	"Sep", "Oct", "Nov", "Dec",
64*7c478bd9Sstevel@tonic-gate };
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate static char mon[] = {
67*7c478bd9Sstevel@tonic-gate 	0,
68*7c478bd9Sstevel@tonic-gate 	31, 29, 31, 30,
69*7c478bd9Sstevel@tonic-gate 	31, 30, 31, 31,
70*7c478bd9Sstevel@tonic-gate 	30, 31, 30, 31,
71*7c478bd9Sstevel@tonic-gate };
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate static char *myname;
74*7c478bd9Sstevel@tonic-gate static char string[432];
75*7c478bd9Sstevel@tonic-gate static struct tm *thetime;
76*7c478bd9Sstevel@tonic-gate static time_t timbuf;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate int
79*7c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
80*7c478bd9Sstevel@tonic-gate {
81*7c478bd9Sstevel@tonic-gate 	int y, i, j;
82*7c478bd9Sstevel@tonic-gate 	int m;
83*7c478bd9Sstevel@tonic-gate 	char *time_locale;
84*7c478bd9Sstevel@tonic-gate 	char	*ldayw;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate 	myname = argv[0];
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate 	(void) setlocale(LC_ALL, "");
89*7c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
90*7c478bd9Sstevel@tonic-gate #define	TEXT_DOMAIN	"SYS_TEST"
91*7c478bd9Sstevel@tonic-gate #endif
92*7c478bd9Sstevel@tonic-gate 	(void) textdomain(TEXT_DOMAIN);
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate 	while (getopt(argc, argv, "") != EOF)
96*7c478bd9Sstevel@tonic-gate 		usage();
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate 	argc -= optind;
99*7c478bd9Sstevel@tonic-gate 	argv  = &argv[optind];
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate 	time_locale = setlocale(LC_TIME, NULL);
102*7c478bd9Sstevel@tonic-gate 	if ((time_locale[0] != 'C') || (time_locale[1] != '\0'))
103*7c478bd9Sstevel@tonic-gate 		load_months();
104*7c478bd9Sstevel@tonic-gate 
105*7c478bd9Sstevel@tonic-gate 	/*
106*7c478bd9Sstevel@tonic-gate 	 * TRANSLATION_NOTE
107*7c478bd9Sstevel@tonic-gate 	 * This message is to be used for displaying
108*7c478bd9Sstevel@tonic-gate 	 * the names of the seven days, from Sunday to Saturday.
109*7c478bd9Sstevel@tonic-gate 	 * The length of the name of each one should be two or less.
110*7c478bd9Sstevel@tonic-gate 	 */
111*7c478bd9Sstevel@tonic-gate 	ldayw = dcgettext(NULL, DAYW, LC_TIME);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate 	switch (argc) {
114*7c478bd9Sstevel@tonic-gate 	case 0:
115*7c478bd9Sstevel@tonic-gate 		timbuf = time(&timbuf);
116*7c478bd9Sstevel@tonic-gate 		thetime = localtime(&timbuf);
117*7c478bd9Sstevel@tonic-gate 		m = thetime->tm_mon + 1;
118*7c478bd9Sstevel@tonic-gate 		y = thetime->tm_year + 1900;
119*7c478bd9Sstevel@tonic-gate 		break;
120*7c478bd9Sstevel@tonic-gate 	case 1:
121*7c478bd9Sstevel@tonic-gate 		goto xlong;
122*7c478bd9Sstevel@tonic-gate 	case 2:
123*7c478bd9Sstevel@tonic-gate 		m = number(argv[0]);
124*7c478bd9Sstevel@tonic-gate 		y = number(argv[1]);
125*7c478bd9Sstevel@tonic-gate 		break;
126*7c478bd9Sstevel@tonic-gate 	default:
127*7c478bd9Sstevel@tonic-gate 		usage();
128*7c478bd9Sstevel@tonic-gate 	}
129*7c478bd9Sstevel@tonic-gate 
130*7c478bd9Sstevel@tonic-gate /*
131*7c478bd9Sstevel@tonic-gate  *	print out just month
132*7c478bd9Sstevel@tonic-gate  */
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate 	if (m < 1 || m > 12)
135*7c478bd9Sstevel@tonic-gate 		badmonth();
136*7c478bd9Sstevel@tonic-gate 	if (y < 1 || y > 9999)
137*7c478bd9Sstevel@tonic-gate 		badyear();
138*7c478bd9Sstevel@tonic-gate 	/*
139*7c478bd9Sstevel@tonic-gate 	 * TRANSLATION_NOTE
140*7c478bd9Sstevel@tonic-gate 	 * This message is to be used for displaying
141*7c478bd9Sstevel@tonic-gate 	 * specified month and year.
142*7c478bd9Sstevel@tonic-gate 	 */
143*7c478bd9Sstevel@tonic-gate 	(void) printf(dcgettext(NULL, TITLE, LC_TIME), months[m-1], y);
144*7c478bd9Sstevel@tonic-gate 	(void) printf("%s\n", ldayw);
145*7c478bd9Sstevel@tonic-gate 	cal(m, y, string, 24);
146*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < 6*24; i += 24)
147*7c478bd9Sstevel@tonic-gate 		pstr(string+i, 24);
148*7c478bd9Sstevel@tonic-gate 	return (0);
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate /*
151*7c478bd9Sstevel@tonic-gate  *	print out complete year
152*7c478bd9Sstevel@tonic-gate  */
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate xlong:
155*7c478bd9Sstevel@tonic-gate 	y = number(argv[0]);
156*7c478bd9Sstevel@tonic-gate 	if (y < 1 || y > 9999)
157*7c478bd9Sstevel@tonic-gate 		badyear();
158*7c478bd9Sstevel@tonic-gate 	/*
159*7c478bd9Sstevel@tonic-gate 	 * TRANSLATION_NOTE
160*7c478bd9Sstevel@tonic-gate 	 * This message is to be used for displaying
161*7c478bd9Sstevel@tonic-gate 	 * specified year.
162*7c478bd9Sstevel@tonic-gate 	 */
163*7c478bd9Sstevel@tonic-gate 	(void) printf(dcgettext(NULL, YEAR, LC_TIME), y);
164*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < 12; i += 3) {
165*7c478bd9Sstevel@tonic-gate 		for (j = 0; j < 6*72; j++)
166*7c478bd9Sstevel@tonic-gate 			string[j] = '\0';
167*7c478bd9Sstevel@tonic-gate 		/*
168*7c478bd9Sstevel@tonic-gate 		 * TRANSLATION_NOTE
169*7c478bd9Sstevel@tonic-gate 		 * This message is to be used for displaying
170*7c478bd9Sstevel@tonic-gate 		 * names of three months per a line and should be
171*7c478bd9Sstevel@tonic-gate 		 * correctly translated according to the display width
172*7c478bd9Sstevel@tonic-gate 		 * of the names of months.
173*7c478bd9Sstevel@tonic-gate 		 */
174*7c478bd9Sstevel@tonic-gate 		(void) printf(
175*7c478bd9Sstevel@tonic-gate 			dcgettext(NULL, MONTH, LC_TIME),
176*7c478bd9Sstevel@tonic-gate 			short_months[i], short_months[i+1], short_months[i+2]);
177*7c478bd9Sstevel@tonic-gate 		(void) printf("%s   %s   %s\n", ldayw, ldayw, ldayw);
178*7c478bd9Sstevel@tonic-gate 		cal(i+1, y, string, 72);
179*7c478bd9Sstevel@tonic-gate 		cal(i+2, y, string+23, 72);
180*7c478bd9Sstevel@tonic-gate 		cal(i+3, y, string+46, 72);
181*7c478bd9Sstevel@tonic-gate 		for (j = 0; j < 6*72; j += 72)
182*7c478bd9Sstevel@tonic-gate 			pstr(string+j, 72);
183*7c478bd9Sstevel@tonic-gate 	}
184*7c478bd9Sstevel@tonic-gate 	(void) printf("\n\n\n");
185*7c478bd9Sstevel@tonic-gate 	return (0);
186*7c478bd9Sstevel@tonic-gate }
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate static int
189*7c478bd9Sstevel@tonic-gate number(char *str)
190*7c478bd9Sstevel@tonic-gate {
191*7c478bd9Sstevel@tonic-gate 	int n, c;
192*7c478bd9Sstevel@tonic-gate 	char *s;
193*7c478bd9Sstevel@tonic-gate 
194*7c478bd9Sstevel@tonic-gate 	n = 0;
195*7c478bd9Sstevel@tonic-gate 	s = str;
196*7c478bd9Sstevel@tonic-gate 	/*LINTED*/
197*7c478bd9Sstevel@tonic-gate 	while (c = *s++) {
198*7c478bd9Sstevel@tonic-gate 		if (c < '0' || c > '9')
199*7c478bd9Sstevel@tonic-gate 			return (0);
200*7c478bd9Sstevel@tonic-gate 		n = n*10 + c-'0';
201*7c478bd9Sstevel@tonic-gate 	}
202*7c478bd9Sstevel@tonic-gate 	return (n);
203*7c478bd9Sstevel@tonic-gate }
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate static void
206*7c478bd9Sstevel@tonic-gate pstr(char *str, const int n)
207*7c478bd9Sstevel@tonic-gate {
208*7c478bd9Sstevel@tonic-gate 	int i;
209*7c478bd9Sstevel@tonic-gate 	char *s;
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate 	s = str;
212*7c478bd9Sstevel@tonic-gate 	i = n;
213*7c478bd9Sstevel@tonic-gate 	while (i--)
214*7c478bd9Sstevel@tonic-gate 		if (*s++ == '\0')
215*7c478bd9Sstevel@tonic-gate 			s[-1] = ' ';
216*7c478bd9Sstevel@tonic-gate 	i = n+1;
217*7c478bd9Sstevel@tonic-gate 	while (i--)
218*7c478bd9Sstevel@tonic-gate 		if (*--s != ' ')
219*7c478bd9Sstevel@tonic-gate 			break;
220*7c478bd9Sstevel@tonic-gate 	s[1] = '\0';
221*7c478bd9Sstevel@tonic-gate 	(void) printf("%s\n", str);
222*7c478bd9Sstevel@tonic-gate }
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate static void
225*7c478bd9Sstevel@tonic-gate cal(const int m, const int y, char *p, const int w)
226*7c478bd9Sstevel@tonic-gate {
227*7c478bd9Sstevel@tonic-gate 	int d, i;
228*7c478bd9Sstevel@tonic-gate 	char *s;
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate 	s = (char *)p;
231*7c478bd9Sstevel@tonic-gate 	d = jan1(y);
232*7c478bd9Sstevel@tonic-gate 	mon[2] = 29;
233*7c478bd9Sstevel@tonic-gate 	mon[9] = 30;
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate 	switch ((jan1(y+1)+7-d)%7) {
236*7c478bd9Sstevel@tonic-gate 
237*7c478bd9Sstevel@tonic-gate 	/*
238*7c478bd9Sstevel@tonic-gate 	 *	non-leap year
239*7c478bd9Sstevel@tonic-gate 	 */
240*7c478bd9Sstevel@tonic-gate 	case 1:
241*7c478bd9Sstevel@tonic-gate 		mon[2] = 28;
242*7c478bd9Sstevel@tonic-gate 		break;
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate 	/*
245*7c478bd9Sstevel@tonic-gate 	 *	1752
246*7c478bd9Sstevel@tonic-gate 	 */
247*7c478bd9Sstevel@tonic-gate 	default:
248*7c478bd9Sstevel@tonic-gate 		mon[9] = 19;
249*7c478bd9Sstevel@tonic-gate 		break;
250*7c478bd9Sstevel@tonic-gate 
251*7c478bd9Sstevel@tonic-gate 	/*
252*7c478bd9Sstevel@tonic-gate 	 *	leap year
253*7c478bd9Sstevel@tonic-gate 	 */
254*7c478bd9Sstevel@tonic-gate 	case 2:
255*7c478bd9Sstevel@tonic-gate 		;
256*7c478bd9Sstevel@tonic-gate 	}
257*7c478bd9Sstevel@tonic-gate 	for (i = 1; i < m; i++)
258*7c478bd9Sstevel@tonic-gate 		d += mon[i];
259*7c478bd9Sstevel@tonic-gate 	d %= 7;
260*7c478bd9Sstevel@tonic-gate 	s += 3*d;
261*7c478bd9Sstevel@tonic-gate 	for (i = 1; i <= mon[m]; i++) {
262*7c478bd9Sstevel@tonic-gate 		if (i == 3 && mon[m] == 19) {
263*7c478bd9Sstevel@tonic-gate 			i += 11;
264*7c478bd9Sstevel@tonic-gate 			mon[m] += 11;
265*7c478bd9Sstevel@tonic-gate 		}
266*7c478bd9Sstevel@tonic-gate 		if (i > 9)
267*7c478bd9Sstevel@tonic-gate 			*s = i/10+'0';
268*7c478bd9Sstevel@tonic-gate 		s++;
269*7c478bd9Sstevel@tonic-gate 		*s++ = i%10+'0';
270*7c478bd9Sstevel@tonic-gate 		s++;
271*7c478bd9Sstevel@tonic-gate 		if (++d == 7) {
272*7c478bd9Sstevel@tonic-gate 			d = 0;
273*7c478bd9Sstevel@tonic-gate 			s = p+w;
274*7c478bd9Sstevel@tonic-gate 			p = s;
275*7c478bd9Sstevel@tonic-gate 		}
276*7c478bd9Sstevel@tonic-gate 	}
277*7c478bd9Sstevel@tonic-gate }
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate /*
280*7c478bd9Sstevel@tonic-gate  *	return day of the week
281*7c478bd9Sstevel@tonic-gate  *	of jan 1 of given year
282*7c478bd9Sstevel@tonic-gate  */
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate static int
285*7c478bd9Sstevel@tonic-gate jan1(const int yr)
286*7c478bd9Sstevel@tonic-gate {
287*7c478bd9Sstevel@tonic-gate 	int y, d;
288*7c478bd9Sstevel@tonic-gate 
289*7c478bd9Sstevel@tonic-gate /*
290*7c478bd9Sstevel@tonic-gate  *	normal gregorian calendar
291*7c478bd9Sstevel@tonic-gate  *	one extra day per four years
292*7c478bd9Sstevel@tonic-gate  */
293*7c478bd9Sstevel@tonic-gate 
294*7c478bd9Sstevel@tonic-gate 	y = yr;
295*7c478bd9Sstevel@tonic-gate 	d = 4+y+(y+3)/4;
296*7c478bd9Sstevel@tonic-gate 
297*7c478bd9Sstevel@tonic-gate /*
298*7c478bd9Sstevel@tonic-gate  *	julian calendar
299*7c478bd9Sstevel@tonic-gate  *	regular gregorian
300*7c478bd9Sstevel@tonic-gate  *	less three days per 400
301*7c478bd9Sstevel@tonic-gate  */
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 	if (y > 1800) {
304*7c478bd9Sstevel@tonic-gate 		d -= (y-1701)/100;
305*7c478bd9Sstevel@tonic-gate 		d += (y-1601)/400;
306*7c478bd9Sstevel@tonic-gate 	}
307*7c478bd9Sstevel@tonic-gate 
308*7c478bd9Sstevel@tonic-gate /*
309*7c478bd9Sstevel@tonic-gate  *	great calendar changeover instant
310*7c478bd9Sstevel@tonic-gate  */
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate 	if (y > 1752)
313*7c478bd9Sstevel@tonic-gate 		d += 3;
314*7c478bd9Sstevel@tonic-gate 
315*7c478bd9Sstevel@tonic-gate 	return (d%7);
316*7c478bd9Sstevel@tonic-gate }
317*7c478bd9Sstevel@tonic-gate 
318*7c478bd9Sstevel@tonic-gate static void
319*7c478bd9Sstevel@tonic-gate load_months(void)
320*7c478bd9Sstevel@tonic-gate {
321*7c478bd9Sstevel@tonic-gate 	int month;
322*7c478bd9Sstevel@tonic-gate 
323*7c478bd9Sstevel@tonic-gate 	for (month = MON_1; month <= MON_12; month++)
324*7c478bd9Sstevel@tonic-gate 		months[month - MON_1] = nl_langinfo(month);
325*7c478bd9Sstevel@tonic-gate 	for (month = ABMON_1; month <= ABMON_12; month++)
326*7c478bd9Sstevel@tonic-gate 		short_months[month - ABMON_1] = nl_langinfo(month);
327*7c478bd9Sstevel@tonic-gate }
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate static void
330*7c478bd9Sstevel@tonic-gate badmonth()
331*7c478bd9Sstevel@tonic-gate {
332*7c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("%s: bad month\n"), myname);
333*7c478bd9Sstevel@tonic-gate 	usage();
334*7c478bd9Sstevel@tonic-gate }
335*7c478bd9Sstevel@tonic-gate 
336*7c478bd9Sstevel@tonic-gate static void
337*7c478bd9Sstevel@tonic-gate badyear()
338*7c478bd9Sstevel@tonic-gate {
339*7c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("%s: bad year\n"), myname);
340*7c478bd9Sstevel@tonic-gate 	usage();
341*7c478bd9Sstevel@tonic-gate }
342*7c478bd9Sstevel@tonic-gate 
343*7c478bd9Sstevel@tonic-gate static void
344*7c478bd9Sstevel@tonic-gate usage(void)
345*7c478bd9Sstevel@tonic-gate {
346*7c478bd9Sstevel@tonic-gate 	(void) fprintf(stderr, gettext("usage: %s [ [month] year ]\n"), myname);
347*7c478bd9Sstevel@tonic-gate 	exit(1);
348*7c478bd9Sstevel@tonic-gate }
349