date.c (7ca215a69037714e5f3cb65c394d3467621daa4c) date.c (698f86e401d193b01b09cf1ae7d1a26a5652deac)
1/*
2 * Copyright (c) 1985, 1987, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*
2 * Copyright (c) 1985, 1987, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $Id: date.c,v 1.13 1997/06/06 06:34:37 charnier Exp $
33 * $Id: date.c,v 1.14 1997/08/04 03:37:06 brian Exp $
34 */
35
36#ifndef lint
37static char const copyright[] =
38"@(#) Copyright (c) 1985, 1987, 1988, 1993\n\
39 The Regents of the University of California. All rights reserved.\n";
40#endif /* not lint */
41

--- 42 unchanged lines hidden (view full) ---

84 const struct vary *badv;
85 struct tm lt;
86
87 v = NULL;
88 (void) setlocale(LC_TIME, "");
89 tz.tz_dsttime = tz.tz_minuteswest = 0;
90 rflag = 0;
91 set_timezone = 0;
34 */
35
36#ifndef lint
37static char const copyright[] =
38"@(#) Copyright (c) 1985, 1987, 1988, 1993\n\
39 The Regents of the University of California. All rights reserved.\n";
40#endif /* not lint */
41

--- 42 unchanged lines hidden (view full) ---

84 const struct vary *badv;
85 struct tm lt;
86
87 v = NULL;
88 (void) setlocale(LC_TIME, "");
89 tz.tz_dsttime = tz.tz_minuteswest = 0;
90 rflag = 0;
91 set_timezone = 0;
92 while ((ch = getopt(argc, argv, "D:W:M:Y:d:nr:ut:")) != -1)
92 while ((ch = getopt(argc, argv, "d:nr:ut:v:")) != -1)
93 switch((char)ch) {
94 case 'd': /* daylight savings time */
95 tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
96 if (endptr == optarg || *endptr != '\0')
97 usage();
98 set_timezone = 1;
99 break;
100 case 'n': /* don't set network */

--- 8 unchanged lines hidden (view full) ---

109 break;
110 case 't': /* minutes west of GMT */
111 /* error check; don't allow "PST" */
112 tz.tz_minuteswest = strtol(optarg, &endptr, 10);
113 if (endptr == optarg || *endptr != '\0')
114 usage();
115 set_timezone = 1;
116 break;
93 switch((char)ch) {
94 case 'd': /* daylight savings time */
95 tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
96 if (endptr == optarg || *endptr != '\0')
97 usage();
98 set_timezone = 1;
99 break;
100 case 'n': /* don't set network */

--- 8 unchanged lines hidden (view full) ---

109 break;
110 case 't': /* minutes west of GMT */
111 /* error check; don't allow "PST" */
112 tz.tz_minuteswest = strtol(optarg, &endptr, 10);
113 if (endptr == optarg || *endptr != '\0')
114 usage();
115 set_timezone = 1;
116 break;
117 case 'D':
118 case 'W':
119 case 'M':
120 case 'Y':
121 v = vary_append(v, ch, optarg);
117 case 'v':
118 v = vary_append(v, optarg);
122 break;
123 default:
124 usage();
125 }
126 argc -= optind;
127 argv += optind;
128
129 /*

--- 20 unchanged lines hidden (view full) ---

150 }
151
152 if (*argv && **argv == '+')
153 format = *argv + 1;
154
155 lt = *localtime(&tval);
156 badv = vary_apply(v, &lt);
157 if (badv) {
119 break;
120 default:
121 usage();
122 }
123 argc -= optind;
124 argv += optind;
125
126 /*

--- 20 unchanged lines hidden (view full) ---

147 }
148
149 if (*argv && **argv == '+')
150 format = *argv + 1;
151
152 lt = *localtime(&tval);
153 badv = vary_apply(v, &lt);
154 if (badv) {
158 fprintf(stderr, "-%c %s: Cannot apply date adjustment\n",
159 badv->flag, badv->arg);
155 fprintf(stderr, "%s: Cannot apply date adjustment\n",
156 badv->arg);
160 vary_destroy(v);
161 usage();
162 }
163 vary_destroy(v);
164 (void)strftime(buf, sizeof(buf), format, &lt);
165 (void)printf("%s\n", buf);
166 exit(retval);
167}

--- 85 unchanged lines hidden (view full) ---

253 warnx("illegal time format");
254 usage();
255}
256
257static void
258usage()
259{
260 (void)fprintf(stderr, "%s\n%s\n",
157 vary_destroy(v);
158 usage();
159 }
160 vary_destroy(v);
161 (void)strftime(buf, sizeof(buf), format, &lt);
162 (void)printf("%s\n", buf);
163 exit(retval);
164}

--- 85 unchanged lines hidden (view full) ---

250 warnx("illegal time format");
251 usage();
252}
253
254static void
255usage()
256{
257 (void)fprintf(stderr, "%s\n%s\n",
261 "usage: date [-nu] [-d dst] [-r seconds] [-t west] [+format]",
262 " [-DWMY [+|-]val] [[[[yy]mm]dd]HH]MM[.ss]]");
258 "usage: date [-nu] [-d dst] [-r seconds] [-t west] [+format]",
259 " [-v [+|-]val[ymwdHM]]... [[[[yy]mm]dd]HH]MM[.ss]]");
263 exit(1);
264}
260 exit(1);
261}