Commits

Palmer, 2E0EOL committed eaf6931

Code to process -T parameter (start,end dates).

Comments (0)

Files changed (2)

 
 Package: dlmlstat
 Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, perl, libmail-box-perl, libboolean-perl, libmongodb-perl
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends}, perl, libmail-box-perl, libboolean-perl, libmongodb-perl, perl-modules
 Description: Daybo Logic Mailing list analyser
  Interesting statistics about mailing lists, from processing a Maildir
 use Getopt::Std;
 use Data::Dumper;
 use boolean ':all';
+use Time::Local;
 use strict;
 use warnings;
 use diagnostics;
 {
 	my ( $RefTS, $OptT ) = @_;
 	#TODO: Split the dates here
+	my @dates;
+	return $RefTS unless ( $OptT );
+	@dates = split(m',', $OptT);
+	foreach my $date ( @dates ) {
+		my $dest = 'start';
+		if ( $date =~ m/^(\d{4})\-(\d{2})\-(\d{2})$/ ) {
+			my ( $year, $mon, $mday ) = ( $1, $2, $3 );
+			my $ts = timegm(
+				0, # sec
+				0, # min
+				0, # hour
+				$mday,
+				$mon,
+				$year
+			);
+			$dest = 'end' if ( $RefTS->{'start'} ); # Done start? Now to end
+			$RefTS->{$dest} = $ts;
+		} else {
+			die(sprintf("Invalid time, should match YYYY-MM-DD: %s\n", $date));
+		}
+	}
+	return $RefTS;
 }
 
 sub Main()