Display times in RFC2822 form rather than using ctime(3), since

the former is more explicit about the timezone offset.
This commit is contained in:
lukem 2007-05-24 05:05:18 +00:00
parent 6ca11a7da7
commit f4f2ed1c79
7 changed files with 42 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.122 2007/05/10 05:35:31 lukem Exp $ */
/* $NetBSD: cmds.c,v 1.123 2007/05/24 05:05:18 lukem Exp $ */
/*-
* Copyright (c) 1996-2007 The NetBSD Foundation, Inc.
@ -103,7 +103,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: cmds.c,v 1.122 2007/05/10 05:35:31 lukem Exp $");
__RCSID("$NetBSD: cmds.c,v 1.123 2007/05/24 05:05:18 lukem Exp $");
#endif
#endif /* not lint */
@ -2495,7 +2495,8 @@ modtime(int argc, char *argv[])
}
mtime = remotemodtime(argv[1], 1);
if (mtime != -1)
fprintf(ttyout, "%s\t%s", argv[1], asctime(localtime(&mtime)));
fprintf(ttyout, "%s\t%s", argv[1],
rfc2822time(localtime(&mtime)));
code = (mtime > 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.71 2007/04/18 01:39:04 lukem Exp $ */
/* $NetBSD: extern.h,v 1.72 2007/05/24 05:05:18 lukem Exp $ */
/*-
* Copyright (c) 1996-2007 The NetBSD Foundation, Inc.
@ -195,6 +195,7 @@ void removedir(int, char **);
void renamefile(int, char **);
void reset(int, char **);
void restart(int, char **);
const char *rfc2822time(const struct tm *);
void rmthelp(int, char **);
void rmtstatus(int, char **);
char *rprompt(void);

View File

@ -1,4 +1,4 @@
/* $NetBSD: fetch.c,v 1.178 2007/05/22 05:16:48 lukem Exp $ */
/* $NetBSD: fetch.c,v 1.179 2007/05/24 05:05:18 lukem Exp $ */
/*-
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fetch.c,v 1.178 2007/05/22 05:16:48 lukem Exp $");
__RCSID("$NetBSD: fetch.c,v 1.179 2007/05/24 05:05:18 lukem Exp $");
#endif /* not lint */
/*
@ -949,7 +949,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
if (ftp_debug && mtime != -1) {
fprintf(ttyout,
"parsed date as: %s",
ctime(&mtime));
rfc2822time(localtime(&mtime)));
}
#endif
}
@ -1248,7 +1248,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
if (utimes(savefile, tval) == -1) {
fprintf(ttyout,
"Can't change modification time to %s",
asctime(localtime(&mtime)));
rfc2822time(localtime(&mtime)));
}
}
if (bytes > 0)

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ftp.1,v 1.117 2007/05/15 23:54:19 lukem Exp $
.\" $NetBSD: ftp.1,v 1.118 2007/05/24 05:05:18 lukem Exp $
.\"
.\" Copyright (c) 1996-2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -64,7 +64,7 @@
.\"
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\"
.Dd April 16, 2007
.Dd May 24, 2007
.Dt FTP 1
.Os
.Sh NAME
@ -787,7 +787,9 @@ The default (and only supported)
mode is
.Dq stream .
.It Ic modtime Ar remote-file
Show the last modification time of the file on the remote machine.
Show the last modification time of the file on the remote machine, in
.Li RFC2822
format.
.It Ic more Ar file
A synonym for
.Ic page .
@ -2377,6 +2379,8 @@ attempts to be compliant with:
.Em FTP Extensions for IPv6 and NATs
.It Li RFC2616
.Em Hypertext Transfer Protocol -- HTTP/1.1
.It Li RFC2822
.Em Internet Message Format
.It Li RFC3659
.Em Extensions to FTP
.It Li RFC3986

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp.c,v 1.150 2007/05/15 23:54:19 lukem Exp $ */
/* $NetBSD: ftp.c,v 1.151 2007/05/24 05:05:19 lukem Exp $ */
/*-
* Copyright (c) 1996-2007 The NetBSD Foundation, Inc.
@ -99,7 +99,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
__RCSID("$NetBSD: ftp.c,v 1.150 2007/05/15 23:54:19 lukem Exp $");
__RCSID("$NetBSD: ftp.c,v 1.151 2007/05/24 05:05:19 lukem Exp $");
#endif
#endif /* not lint */
@ -1146,7 +1146,8 @@ recvrequest(const char *cmd, const char *volatile local, const char *remote,
if (utimes(local, tval) == -1) {
fprintf(ttyout,
"Can't change modification time on %s to %s",
local, asctime(localtime(&mtime)));
local,
rfc2822time(localtime(&mtime)));
}
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.142 2007/05/24 02:51:41 lukem Exp $ */
/* $NetBSD: util.c,v 1.143 2007/05/24 05:05:19 lukem Exp $ */
/*-
* Copyright (c) 1997-2007 The NetBSD Foundation, Inc.
@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.142 2007/05/24 02:51:41 lukem Exp $");
__RCSID("$NetBSD: util.c,v 1.143 2007/05/24 05:05:19 lukem Exp $");
#endif /* not lint */
/*
@ -764,7 +764,8 @@ remotemodtime(const char *file, int noisy)
goto cleanup_parse_time;
} else
DPRINTF("parsed date `%s' as " LLF ", %s",
timestr, (LLT)rtime, ctime(&rtime));
timestr, (LLT)rtime,
rfc2822time(localtime(&rtime)));
} else {
if (r == ERROR && code == 500 && features[FEAT_MDTM] == -1)
features[FEAT_MDTM] = 0;
@ -780,6 +781,21 @@ remotemodtime(const char *file, int noisy)
return (rtime);
}
/*
* Format tm in an RFC2822 compatible manner, with a trailing \n.
* Returns a pointer to a static string containing the result.
*/
const char *
rfc2822time(const struct tm *tm)
{
static char result[50];
if (strftime(result, sizeof(result),
"%a, %d %b %Y %H:%M:%S %z\n", tm) == 0)
errx(1, "Can't convert RFC2822 time: buffer too small");
return result;
}
/*
* Update global `localcwd', which contains the state of the local cwd
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.h,v 1.66 2007/05/22 05:16:48 lukem Exp $ */
/* $NetBSD: version.h,v 1.67 2007/05/24 05:05:19 lukem Exp $ */
/*-
* Copyright (c) 1999-2007 The NetBSD Foundation, Inc.
* All rights reserved.
@ -40,5 +40,5 @@
#endif
#ifndef FTP_VERSION
#define FTP_VERSION "20070522"
#define FTP_VERSION "20070524"
#endif