/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
/*
* date - with format capabilities and international flair
*/
#include <locale.h>
#include <fcntl.h>
#include <langinfo.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ctype.h>
#include <utmpx.h>
#include <tzfile.h>
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
};
static char *usage =
"usage:\tdate [-u] mmddHHMM[[cc]yy][.SS]\n\tdate [-Ru] [+format]\n"
"\tdate -a [-]sss[.fff]\n";
static int uflag = 0;
static int Rflag = 0;
static void fmt_extensions(char *, size_t,
const char *, const struct timespec *);
int
{
char *fmt;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'a':
aflag++;
gettext("date: invalid argument -- %s\n"),
optarg);
illflag++;
}
break;
case 'u':
uflag++;
break;
case 'R':
Rflag++;
break;
default:
illflag++;
}
/* -a is mutually exclusive with -u and -R */
illflag++;
illflag++;
if (illflag) {
exit(1);
}
exit(1);
}
if (aflag) {
exit(1);
}
exit(0);
}
if (argc > 0) {
if (*argv[0] == '+')
else {
exit(1);
}
}
} else if (Rflag) {
fmt = "%a, %d %h %Y %H:%M:%S %z";
} else
if (uflag) {
(void) putenv("TZ=GMT0");
tzset();
} else
return (0);
}
int
{
int i;
int mm;
int hh;
int min;
int sec = 0;
char *secptr;
int yy;
int dd = 0;
int len;
int dd_check;
/* Parse date string */
for (i = 0; i < len; i++) {
gettext("date: bad conversion\n"));
exit(1);
}
}
case 12:
break;
case 10:
/*
* The YY format has the following representation:
* 00-68 = 2000 thru 2068
* 69-99 = 1969 thru 1999
*/
} else {
}
break;
case 8:
break;
case 4:
minidx = 2;
break;
default:
return (1);
}
if (!dd) {
/*
* if dd is 0 (not between 1 and 31), then
* read the value supplied by the user.
*/
}
if (hh == 24)
/* Validate date elements */
dd_check = 0;
dd_check++;
}
return (1);
}
/* Build date and time number */
/* Adjust for leap year */
clock_val += 1;
/* Adjust for different month lengths */
while (--mm)
/* Load up the rest */
clock_val *= 24;
clock_val *= 60;
clock_val *= 60;
if (!uflag) {
/* convert to GMT assuming standard time */
/* correction is made in localtime(3C) */
/*
* call localtime to set up "timezone" variable applicable
* for clock_val time, to support Olson timezones which
* can allow timezone rules to change.
*/
/* correct if daylight savings time in effect */
}
perror("date");
return (1);
}
#if defined(i386)
/* correct the kernel's "gmt_lag" and the PC's RTC */
#endif
(void) pututxline(&wtmpx[0]);
return (0);
}
int
{
register int mult;
int sign;
/* arg must be [-]sss[.fff] */
if (*cp == '-') {
sign = -1;
cp++;
} else {
sign = 1;
}
}
if (*cp == '.') {
cp++;
mult = 100000;
mult /= 10;
}
}
/*
* if there's anything left in the string,
* the input was invalid.
*/
if (*cp) {
return (-1);
} else {
return (0);
}
}
/*
* Extensions that cannot be interpreted by strftime are interpreted here.
*/
void
{
const char *p;
char *q;
if (*p == '%') {
switch (*(p + 1)) {
case 'N':
++p;
continue;
}
}
*q++ = *p;
}
*q = '\0';
else
}