Date: Fri, 30 Mar 2001 04:40:03 -0800 (PST) From: Peter Pentchev <roam@orbitel.bg> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/24166: Allow Date to generate an RFC-822 Compliant output. Message-ID: <200103301240.f2UCe3U30097@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/24166; it has been noted by GNATS.
From: Peter Pentchev <roam@orbitel.bg>
To: taz@lagmonster.org
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/24166: Allow Date to generate an RFC-822 Compliant output.
Date: Fri, 30 Mar 2001 15:32:44 +0300
I don't see too many people interested in such new functionality
in date(1); however, you could try the attached patch on your
local systems (it is against -current, but applies cleanly to -stable).
G'luck,
Peter
--
This sentence claims to be an Epimenides paradox, but it is lying.
On Mon, Jan 08, 2001 at 11:40:03PM -0800, Peter Pentchev wrote:
> The following reply was made to PR misc/24166; it has been noted by GNATS.
>
> From: Peter Pentchev <roam@orbitel.bg>
> To: taz@lagmonster.org
> Cc: freebsd-gnats-submit@FreeBSD.org
> Subject: Re: misc/24166: Allow Date to generate an RFC-822 Compliant output.
> Date: Tue, 9 Jan 2001 09:35:49 +0200
>
> On Mon, Jan 08, 2001 at 04:28:27PM -0800, taz@lagmonster.org wrote:
> >
> > >Number: 24166
> > >Category: misc
> > >Synopsis: Allow Date to generate an RFC-822 Compliant output.
> > >Originator: David Alexander
> > >Release: 4.2
> > >Organization:
> > Lagmonster Org.
> > >Environment:
> > No problems.
> > >Description:
> > It would be nice to have Date generate (perhaps with a -R switch) an RFC-822
> > formatted output. It would be nice to be able to offset it. (I am looking for
> > a non-converted format to push cookies and other HTTP standard date format
> > uses.
>
> If you mean date(1) (/bin/date), it can generate output in any format you
> specify. See the date(1) and strftime(3) manpages (strftime.3 is referenced
> in the SEE ALSO section of date.1). For RFC-822 compliant output, use:
>
> date '+%a, %e %b %Y %T %z (%Z)'
>
> You could even make a tiny shell script to do that, if you don't want all
> those format chars in the way:
>
> #!/bin/sh
> exec /bin/date '+%a, %e %b %Y %T %z (%Z)'
>
> Does that suffice? :)
Index: src/bin/date/date.1
===================================================================
RCS file: /home/ncvs/src/bin/date/date.1,v
retrieving revision 1.51
diff -u -r1.51 date.1
--- src/bin/date/date.1 2001/03/16 02:20:24 1.51
+++ src/bin/date/date.1 2001/03/30 12:27:27
@@ -43,7 +43,7 @@
.Nd display or set date and time
.Sh SYNOPSIS
.Nm
-.Op Fl jnu
+.Op Fl Rjnu
.Op Fl d Ar dst
.Op Fl r Ar seconds
.Op Fl t Ar minutes_west
@@ -86,6 +86,8 @@
.Pp
The options are as follows:
.Bl -tag -width Ds
+.It Fl R
+Print the date in RFC-822 format.
.It Fl d Ar dst
Set the kernel's value for daylight saving time.
If
Index: src/bin/date/date.c
===================================================================
RCS file: /home/ncvs/src/bin/date/date.c,v
retrieving revision 1.35
diff -u -r1.35 date.c
--- src/bin/date/date.c 2000/08/16 05:14:49 1.35
+++ src/bin/date/date.c 2001/03/30 12:27:28
@@ -80,6 +80,7 @@
{
struct timezone tz;
int ch, rflag;
+ int Rflag;
int jflag, nflag;
char *format, buf[1024];
char *endptr, *fmt;
@@ -92,11 +93,15 @@
fmt = NULL;
(void) setlocale(LC_TIME, "");
tz.tz_dsttime = tz.tz_minuteswest = 0;
+ Rflag = 0;
rflag = 0;
jflag = nflag = 0;
set_timezone = 0;
- while ((ch = getopt(argc, argv, "d:f:jnr:t:uv:")) != -1)
+ while ((ch = getopt(argc, argv, "Rd:f:jnr:t:uv:")) != -1)
switch((char)ch) {
+ case 'R':
+ Rflag = 1;
+ break;
case 'd': /* daylight savings time */
tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
if (endptr == optarg || *endptr != '\0')
@@ -146,7 +151,10 @@
if (!rflag && time(&tval) == -1)
err(1, "time");
- format = "%+";
+ if (!Rflag)
+ format = "%+";
+ else
+ format = "%a, %e %b %Y %T %z (%Z)";
/* allow the operands in any order */
if (*argv && **argv == '+') {
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103301240.f2UCe3U30097>
