Add the ability to supress the '\n' at the end of the date printed.
This commit is contained in:
parent
0c795d27ea
commit
70a53cd743
@ -33,7 +33,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
|
||||
.\" $Id: date.1,v 1.17 1997/08/30 11:06:35 jmg Exp $
|
||||
.\" $Id: date.1,v 1.18 1997/09/13 16:01:27 wosch Exp $
|
||||
.\"
|
||||
.Dd November 17, 1993
|
||||
.Dt DATE 1
|
||||
@ -46,7 +46,7 @@
|
||||
.Op Fl d Ar dst
|
||||
.Op Fl r Ar seconds
|
||||
.Op Fl t Ar minutes_west
|
||||
.Op Fl nu
|
||||
.Op Fl nsu
|
||||
.Op Cm + Ns Ar format
|
||||
.Op Fl v Ar [+|-]val[ymwdHM]
|
||||
.Ar ...
|
||||
@ -95,6 +95,9 @@ from setting the time for other than the current machine.
|
||||
Print out the date and time in
|
||||
.Ar seconds
|
||||
from the Epoch.
|
||||
.It Fl s
|
||||
Single-line print - don't print final linefeed character, useful for
|
||||
adding dated lines to logfiles generated by shell scripts.
|
||||
.It Fl t
|
||||
Set the kernel's value for minutes west of
|
||||
.Tn GMT .
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: date.c,v 1.17 1997/08/10 16:37:33 brian Exp $
|
||||
* $Id: date.c,v 1.18 1997/09/30 20:06:15 joerg Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -76,7 +76,7 @@ main(argc, argv)
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
struct timezone tz;
|
||||
int ch, rflag;
|
||||
int ch, rflag, sflag;
|
||||
char *format, buf[1024];
|
||||
char *endptr, *fmt;
|
||||
int set_timezone;
|
||||
@ -88,9 +88,9 @@ main(argc, argv)
|
||||
fmt = NULL;
|
||||
(void) setlocale(LC_TIME, "");
|
||||
tz.tz_dsttime = tz.tz_minuteswest = 0;
|
||||
rflag = 0;
|
||||
rflag = sflag = 0;
|
||||
set_timezone = 0;
|
||||
while ((ch = getopt(argc, argv, "d:f:nr:t:uv:")) != -1)
|
||||
while ((ch = getopt(argc, argv, "d:f:nr:st:uv:")) != -1)
|
||||
switch((char)ch) {
|
||||
case 'd': /* daylight savings time */
|
||||
tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
|
||||
@ -108,6 +108,9 @@ main(argc, argv)
|
||||
rflag = 1;
|
||||
tval = atol(optarg);
|
||||
break;
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
case 't': /* minutes west of GMT */
|
||||
/* error check; don't allow "PST" */
|
||||
tz.tz_minuteswest = strtol(optarg, &endptr, 10);
|
||||
@ -164,7 +167,9 @@ main(argc, argv)
|
||||
}
|
||||
vary_destroy(v);
|
||||
(void)strftime(buf, sizeof(buf), format, <);
|
||||
(void)printf("%s\n", buf);
|
||||
(void)printf("%s", buf);
|
||||
if (!sflag)
|
||||
(void)printf("\n");
|
||||
exit(retval);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user