display dates as real dates in Excel export, #23121, update for current RT
authorMark Wells <mark@freeside.biz>
Tue, 18 Aug 2015 05:22:02 +0000 (22:22 -0700)
committerMark Wells <mark@freeside.biz>
Tue, 18 Aug 2015 05:22:02 +0000 (22:22 -0700)
rt/lib/RT/Interface/Web_Vendor.pm
rt/share/html/Elements/ShowCustomFieldDate
rt/share/html/Elements/ShowCustomFieldDateTime
rt/share/html/Search/Elements/ResultsStructuredView
rt/share/html/Search/Results.xls

index c9bff6f..ea3a498 100644 (file)
@@ -423,12 +423,13 @@ sub ProcessColumnMapValue {
     my $value = shift;
     my %args = ( Arguments => [],
                  Escape => 1,
-                 FormatDate => \&default_FormatDate,
                  @_ );
 
+    my $FormatDate = $m->notes('FormatDate') || \&default_FormatDate;
+
     if ( ref $value ) {
         if ( ref $value eq 'RT::Date' ) {
-            return $args{FormatDate}->($value);
+            return $FormatDate->($value);
         } elsif ( UNIVERSAL::isa( $value, 'CODE' ) ) {
             my @tmp = $value->( @{ $args{'Arguments'} } );
             return ProcessColumnMapValue( ( @tmp > 1 ? \@tmp : $tmp[0] ), %args );
index 92ab767..1536935 100644 (file)
  my $content = $Object->Content;
  my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
  $DateObj->Set( Format => 'unknown', Value => $content, Timezone => 'utc'  );
- $content = $DateObj->AsString(Time => 0, Timezone => 'utc');
+ if ($m->notes('FormatDate')) {
+   $content = $m->notes('FormatDate')->($DateObj);
+ } else {
+   $content = $DateObj->AsString(Time => 0, Timezone => 'utc');
+ }
 </%INIT>
 <%$content|n%>
 <%ARGS>
index 2ba873a..e179d6a 100644 (file)
  my $content = $Object->Content;
  my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
  $DateObj->Set( Format => 'ISO', Value => $content );
- $content = $DateObj->AsString;
+ if ($m->notes('FormatDate')) {
+   $content = $m->notes('FormatDate')->($DateObj);
+ } else {
+   $content = $DateObj->AsString;
+ }
 </%INIT>
 <%$content|n%>
 <%ARGS>
index 0e9457c..5b9db4e 100644 (file)
@@ -54,7 +54,6 @@ $Format => undef
 #Callbacks
 $WriteHeader => sub { $RT::Logger->error('WriteHeader callback required'); '' }
 $WriteRow    => sub { $RT::Logger->error('WriteRow callback required'); '' }
-$FormatDate  => sub { $_[0]->AsString }
 </%ARGS>
 <%INIT>
 
@@ -146,7 +145,6 @@ while ( my $Ticket = $Tickets->Next()) {
             push @out, ProcessColumnMapValue(
                 $ColumnMap->{$col}{'value'},
                 Arguments => [ $Ticket, $row ],
-                FormatDate => $FormatDate,
             );
         } #foreach $subcol
         $value = join('', '<span>', @out, '</span>');
index 8b94e22..d9d8356 100644 (file)
@@ -118,11 +118,11 @@ my $WriteRow = sub {
     $row++;
 };
 
-my $FormatDate = sub {
+$m->notes('FormatDate', sub {
     my $DateObj = shift;
     return '' if $DateObj->Unix == 0;
     return time2str('%Y-%m-%dT%H:%M', $DateObj->Unix);
-};
+});
 
 # Write everything to the worksheet
 $m->comp('Elements/ResultsStructuredView',
@@ -132,7 +132,6 @@ $m->comp('Elements/ResultsStructuredView',
           Format        => $Format,
           WriteHeader   => $WriteHeader,
           WriteRow      => $WriteRow,
-          FormatDate    => $FormatDate,
 );
 
 # Set column widths