From 8c024268b5a57b6db1dff28d6ccd84af289f710a Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Fri, 17 Oct 2014 13:54:46 +0200 Subject: [PATCH] MT#9637 Use predefined time if passed --- NGCP/CDR/Export.pm | 12 ++++++++++-- cdr-exporter.pl | 4 +--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/NGCP/CDR/Export.pm b/NGCP/CDR/Export.pm index 865b6ad..d1c8d07 100644 --- a/NGCP/CDR/Export.pm +++ b/NGCP/CDR/Export.pm @@ -77,8 +77,16 @@ sub get_missing_resellers { sub get_ts_for_filename { - my $now = time; - my @now = localtime($now); + my ($xnow) = @_; + + my $now; my @now; + + if(defined $xnow) { + @now = @{ $xnow }; + } else { + $now = time; + @now = localtime($now); + } return sprintf('%04i%02i%02i%02i%02i%02i', $now[5] + 1900, $now[4] + 1, @now[3,2,1,0]); } diff --git a/cdr-exporter.pl b/cdr-exporter.pl index 98f8ffc..6ca48c5 100755 --- a/cdr-exporter.pl +++ b/cdr-exporter.pl @@ -55,6 +55,7 @@ die "Invalid destination directory '".$config->{'default.CDRDIR'}."'\n" my $now = time(); my @now = localtime($now); +my $file_ts = NGCP::CDR::Export::get_ts_for_filename(\@now); my @admin_fields = (); foreach my $f(@{$config->{'default.ADMIN_EXPORT_FIELDS'}}) { @@ -173,8 +174,6 @@ my $reseller_ids = {}; my $reseller_lines = {}; while(my $row = $sth->fetchrow_arrayref) { - # agranig: no quoting of fields - # my @fields = map { defined $_ ? "\"$_\"" : '""' } (@{ $row }); my @fields = @{ $row }; my $id = shift @fields; my $src_uuid = shift @fields; @@ -219,7 +218,6 @@ while(my $row = $sth->fetchrow_arrayref) { my $full_name = (defined $config->{'default.FULL_NAMES'} && $config->{'default.NAMES'} eq "yes" ? 1 : 0); my $monthly_dir = (defined $config->{'default.MONTHLY_DIR'} && $config->{'default.MONTHLY_DIR'} eq "yes" ? 1 : 0); my $daily_dir = (defined $config->{'default.DAILY_DIR'} && $config->{'default.DAILY_DIR'} eq "yes" ? 1 : 0); -my $file_ts = NGCP::CDR::Export::get_ts_for_filename; my $dname = ""; if($monthly_dir && !$daily_dir) { $dname .= sprintf("%04i%02i", $now[5] + 1900, $now[4] + 1);