Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-10]: src/bin/date Pull up following revision(s) (requested by kim...
details: https://anonhg.NetBSD.org/src/rev/d4c00fe548a6
branches: netbsd-10
changeset: 376164:d4c00fe548a6
user: martin <martin%NetBSD.org@localhost>
date: Sat Jun 03 15:23:42 2023 +0000
description:
Pull up following revision(s) (requested by kim in ticket #192):
bin/date/date.1: revision 1.52
bin/date/date.1: revision 1.53
bin/date/date.1: revision 1.54
bin/date/date.c: revision 1.64
bin/date/date.c: revision 1.65
Add -R option for displaying time in RFC 5322 format, similar to GNU date.
date(1): minor markup fixes
Add -R to usage
date(1): sync two [[[[[CC]yy]mm]dd]HH]MM[.SS] instances
The markup was the same (modulo Li vs Cm for the dot before the
seconds), but use the same source markup grouping/layout in both to
make this fact more obvious.
diffstat:
bin/date/date.1 | 44 +++++++++++++++++++++++++++-----------------
bin/date/date.c | 18 ++++++++++++------
2 files changed, 39 insertions(+), 23 deletions(-)
diffs (195 lines):
diff -r 63e505c34d6f -r d4c00fe548a6 bin/date/date.1
--- a/bin/date/date.1 Sat Jun 03 15:16:08 2023 +0000
+++ b/bin/date/date.1 Sat Jun 03 15:23:42 2023 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: date.1,v 1.51 2022/10/22 20:11:43 christos Exp $
+.\" $NetBSD: date.1,v 1.51.2.1 2023/06/03 15:23:42 martin Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
-.Dd October 22, 2022
+.Dd May 31, 2023
.Dt DATE 1
.Os
.Sh NAME
@@ -40,23 +40,26 @@
.Nd display or set date and time
.Sh SYNOPSIS
.Nm
-.Op Fl ajnu
+.Op Fl ajnRu
.Op Fl d Ar date
.Op Fl r Ar seconds
.Op Cm + Ns Ar format
.Sm off
-.Oo Oo Oo Oo Oo Oo
+.Oo
+.Oo Oo Oo Oo Oo
.Ar CC Oc
.Ar yy Oc
.Ar mm Oc
.Ar dd Oc
-.Ar HH Oc Ar MM Oo
-.Li \&. Ar SS Oc Oc
+.Ar HH Oc
+.Ar MM
+.Op Cm \&. Ar SS
+.Oc
.Sm on
.Nm
-.Op Fl ajnu
+.Op Fl ajnRu
.Fl f Ar input_format
-new_date
+.Ar new_date
.Op Cm + Ns Ar format
.Sh DESCRIPTION
.Nm
@@ -66,7 +69,7 @@ way or set the date.
Only the superuser may set the date.
.Pp
The options are as follows:
-.Bl -tag -width 12n
+.Bl -tag -width Fl
.It Fl a
Use
.Xr adjtime 2
@@ -89,12 +92,13 @@ as the format string to parse the
provided rather than using the default
.Sm off
.Oo Oo Oo Oo Oo
-.Ar cc Oc
+.Ar CC Oc
.Ar yy Oc
.Ar mm Oc
.Ar dd Oc
-.Ar HH
-.Oc Ar MM Op Cm \&. Ar SS
+.Ar HH Oc
+.Ar MM
+.Op Cm \&. Ar SS
.Sm on
format.
Parsing is done using
@@ -116,6 +120,9 @@ The
option stops
.Nm
from setting the time for other than the current machine.
+.It Fl R
+Use a default display format that conforms to the date and time
+specification in RFC 5322 (Internet Message Format).
.It Fl r Ar seconds
Print out the date and time that is
.Ar seconds
@@ -132,7 +139,9 @@ The format string may contain any of the
in the
.Xr strftime 3
manual page, as well as any arbitrary text.
-A <newline> character is always output after the characters
+A
+.Aq newline
+character is always output after the characters
specified by the format string.
The format string for the default display is:
.Pp
@@ -178,7 +187,7 @@ and years are handled automatically.
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
-.Bl -tag -width iTZ
+.Bl -tag -width Ev
.It Ev TZ
The timezone to use when displaying dates.
See
@@ -186,13 +195,14 @@ See
for more information.
.El
.Sh FILES
-.Bl -tag -width /usr/share/zoneinfo/posixrules -compact
+.Bl -tag -width Pa -compact
.It Pa /etc/localtime
Symlink pointing to system's default timezone information file in
.Pa /usr/share/zoneinfo
directory.
-.It Pa /usr/lib/locale/<L>/LC_TIME
-Description of time locale <L>.
+.It Pa /usr/lib/locale/ Ns Ao Ar L Ac Ns Pa /LC_TIME
+Description of time locale
+.Aq Ar L .
.It Pa /usr/share/zoneinfo
Time zone information directory.
.It Pa /usr/share/zoneinfo/posixrules
diff -r 63e505c34d6f -r d4c00fe548a6 bin/date/date.c
--- a/bin/date/date.c Sat Jun 03 15:16:08 2023 +0000
+++ b/bin/date/date.c Sat Jun 03 15:23:42 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: date.c,v 1.63 2022/10/22 20:11:43 christos Exp $ */
+/* $NetBSD: date.c,v 1.63.2.1 2023/06/03 15:23:42 martin Exp $ */
/*
* Copyright (c) 1985, 1987, 1988, 1993
@@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: date.c,v 1.63 2022/10/22 20:11:43 christos Exp $");
+__RCSID("$NetBSD: date.c,v 1.63.2.1 2023/06/03 15:23:42 martin Exp $");
#endif
#endif /* not lint */
@@ -71,7 +71,7 @@ static char sccsid[] = "@(#)date.c 8.2 (
#include "extern.h"
static time_t tval;
-static int aflag, jflag, rflag, nflag;
+static int Rflag, aflag, jflag, rflag, nflag;
static char *fmt;
__dead static void badcanotime(const char *, const char *, size_t);
@@ -91,7 +91,7 @@ main(int argc, char *argv[])
setprogname(argv[0]);
(void)setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "ad:f:jnr:u")) != -1) {
+ while ((ch = getopt(argc, argv, "ad:f:jnRr:u")) != -1) {
switch (ch) {
case 'a': /* adjust time slowly */
aflag = 1;
@@ -119,6 +119,9 @@ main(int argc, char *argv[])
case 'n': /* don't set network */
nflag = 1;
break;
+ case 'R': /* RFC-5322 email format */
+ Rflag = 1;
+ break;
case 'r': /* user specified seconds */
if (optarg[0] == '\0') {
errx(EXIT_FAILURE, "<empty>: Invalid number");
@@ -153,6 +156,9 @@ main(int argc, char *argv[])
if (*argv && **argv == '+') {
format = *argv;
++argv;
+ } else if (Rflag) {
+ (void)setlocale(LC_TIME, "C");
+ format = "+%a, %-e %b %Y %H:%M:%S %z";
} else
format = "+%a %b %e %H:%M:%S %Z %Y";
@@ -398,11 +404,11 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "Usage: %s [-ajnu] [-d date] [-r seconds] [+format]",
+ "Usage: %s [-ajnRu] [-d date] [-r seconds] [+format]",
getprogname());
(void)fprintf(stderr, " [[[[[[CC]yy]mm]dd]HH]MM[.SS]]\n");
(void)fprintf(stderr,
- " %s [-ajnu] -f input_format new_date [+format]\n",
+ " %s [-ajnRu] -f input_format new_date [+format]\n",
getprogname());
exit(EXIT_FAILURE);
/* NOTREACHED */
Home |
Main Index |
Thread Index |
Old Index