user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 0/3] misc minor fixups
@ 2016-12-13  3:48 Eric Wong
  2016-12-13  3:48 ` [PATCH 1/3] nntp: add test case for the "DATE" command Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2016-12-13  3:48 UTC (permalink / raw)
  To: meta

Nothing major, just some cleanups I noticed while working on
other stuff...

Eric Wong (3):
      nntp: add test case for the "DATE" command
      nntp: avoid useless use of strftime
      searchmsg: remove unused EPOCH_822 constant

 lib/PublicInbox/NNTP.pm      | 4 ++--
 lib/PublicInbox/SearchMsg.pm | 1 -
 t/nntpd.t                    | 8 ++++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] nntp: add test case for the "DATE" command
  2016-12-13  3:48 [PATCH 0/3] misc minor fixups Eric Wong
@ 2016-12-13  3:48 ` Eric Wong
  2016-12-13  3:48 ` [PATCH 2/3] nntp: avoid useless use of strftime Eric Wong
  2016-12-13  3:48 ` [PATCH 3/3] searchmsg: remove unused EPOCH_822 constant Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-12-13  3:48 UTC (permalink / raw)
  To: meta

We may not always use strftime and may implement caching.
But for now, just add a test.
---
 t/nntpd.t | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/t/nntpd.t b/t/nntpd.t
index 7192d78..ad50a64 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -203,6 +203,14 @@ EOF
 		 'XHDR on invalid header returns empty');
 
 	{
+		my $t0 = time;
+		my $date = $n->date;
+		my $t1 = time;
+		ok($date >= $t0, 'valid date after start');
+		ok($date <= $t1, 'valid date before stop');
+	}
+
+	{
 		setsockopt($s, IPPROTO_TCP, TCP_NODELAY, 1);
 		syswrite($s, 'HDR List-id 1-');
 		select(undef, undef, undef, 0.15);
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] nntp: avoid useless use of strftime
  2016-12-13  3:48 [PATCH 0/3] misc minor fixups Eric Wong
  2016-12-13  3:48 ` [PATCH 1/3] nntp: add test case for the "DATE" command Eric Wong
@ 2016-12-13  3:48 ` Eric Wong
  2016-12-13  3:48 ` [PATCH 3/3] searchmsg: remove unused EPOCH_822 constant Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-12-13  3:48 UTC (permalink / raw)
  To: meta

There's no need to use strftime if we'll be converting the date
by hand, anyways.
---
 lib/PublicInbox/NNTP.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index b7143ff..9408ffb 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -250,8 +250,8 @@ sub parse_time ($$;$) {
 		($YYYY, $MM, $DD) = unpack('A4A2A2', $date);
 	} else { # legacy clients send YYMMDD
 		($YYYY, $MM, $DD) = unpack('A2A2A2', $date);
-		if ($YYYY > strftime('%y', @now)) {
-			my $cur_year = $now[5] + 1900;
+		my $cur_year = $now[5] + 1900;
+		if ($YYYY > $cur_year) {
 			$YYYY += int($cur_year / 1000) * 1000 - 100;
 		}
 	}
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] searchmsg: remove unused EPOCH_822 constant
  2016-12-13  3:48 [PATCH 0/3] misc minor fixups Eric Wong
  2016-12-13  3:48 ` [PATCH 1/3] nntp: add test case for the "DATE" command Eric Wong
  2016-12-13  3:48 ` [PATCH 2/3] nntp: avoid useless use of strftime Eric Wong
@ 2016-12-13  3:48 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-12-13  3:48 UTC (permalink / raw)
  To: meta

This hasn't been needed since our Email::Abstract removal
for message threading.
---
 lib/PublicInbox/SearchMsg.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index 9dcc1e6..5779d1e 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -12,7 +12,6 @@ use Date::Parse qw/str2time/;
 use PublicInbox::MID qw/mid_clean/;
 use PublicInbox::Address;
 our $PFX2TERM_RE = undef;
-use constant EPOCH_822 => 'Thu, 01 Jan 1970 00:00:00 +0000';
 use POSIX qw(strftime);
 
 sub new {
-- 
EW


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-13  3:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-13  3:48 [PATCH 0/3] misc minor fixups Eric Wong
2016-12-13  3:48 ` [PATCH 1/3] nntp: add test case for the "DATE" command Eric Wong
2016-12-13  3:48 ` [PATCH 2/3] nntp: avoid useless use of strftime Eric Wong
2016-12-13  3:48 ` [PATCH 3/3] searchmsg: remove unused EPOCH_822 constant Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).