[Mimedefang] rfc822_date test (was Re: Any way to get MD to accept a Postfix queue ID at RCPT time?)

Dianne Skoll dfs at roaringpenguin.com
Wed Apr 29 11:23:33 EDT 2015

On Wed, 29 Apr 2015 16:53:16 +0200
Fred de Brouwer <brouwerfdb14 at xs4all.nl> wrote:

> It might be worthwhile to check the POSIX strftime Clib-function:

Yes.  And here's the proposed test... far more sane than before
if you consider overriding Perl built-in functions to be "sane" :)

Oh, and the reason we don't use the POSIX module in MIMEDefang is
that it's rather large, so we'd like to avoid pulling it in if
the filter doesn't need it.



use POSIX;
sub rfc2822_date_works : Test(1)
	my $now = time();
	no warnings 'redefine';
	no warnings 'once';
	local *time = sub { return $now; };

	my $want = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($now));
	is(::main::rfc2822_date(), $want, 'Got correct RFC 2822 date');

More information about the MIMEDefang mailing list