diff options
author | Mark Wells <mark@freeside.biz> | 2015-08-17 22:22:02 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-08-17 22:22:02 -0700 |
commit | feba5016425b52740c29653383343d0d1887a592 (patch) | |
tree | a85f4799e35e7682dc734985d77226131db82a2e /rt | |
parent | ef2bc5dcb69e67077ce45a624c107894765e3907 (diff) |
display dates as real dates in Excel export, #23121, update for current RT
Diffstat (limited to 'rt')
-rw-r--r-- | rt/lib/RT/Interface/Web_Vendor.pm | 5 | ||||
-rw-r--r-- | rt/share/html/Elements/ShowCustomFieldDate | 6 | ||||
-rw-r--r-- | rt/share/html/Elements/ShowCustomFieldDateTime | 6 | ||||
-rw-r--r-- | rt/share/html/Search/Elements/ResultsStructuredView | 2 | ||||
-rw-r--r-- | rt/share/html/Search/Results.xls | 5 |
5 files changed, 15 insertions, 9 deletions
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm index c9bff6f..ea3a498 100644 --- a/rt/lib/RT/Interface/Web_Vendor.pm +++ b/rt/lib/RT/Interface/Web_Vendor.pm @@ -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 ); diff --git a/rt/share/html/Elements/ShowCustomFieldDate b/rt/share/html/Elements/ShowCustomFieldDate index 92ab767..1536935 100644 --- a/rt/share/html/Elements/ShowCustomFieldDate +++ b/rt/share/html/Elements/ShowCustomFieldDate @@ -49,7 +49,11 @@ 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> diff --git a/rt/share/html/Elements/ShowCustomFieldDateTime b/rt/share/html/Elements/ShowCustomFieldDateTime index 2ba873a..e179d6a 100644 --- a/rt/share/html/Elements/ShowCustomFieldDateTime +++ b/rt/share/html/Elements/ShowCustomFieldDateTime @@ -49,7 +49,11 @@ 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> diff --git a/rt/share/html/Search/Elements/ResultsStructuredView b/rt/share/html/Search/Elements/ResultsStructuredView index 0e9457c..5b9db4e 100644 --- a/rt/share/html/Search/Elements/ResultsStructuredView +++ b/rt/share/html/Search/Elements/ResultsStructuredView @@ -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>'); diff --git a/rt/share/html/Search/Results.xls b/rt/share/html/Search/Results.xls index 8b94e22..d9d8356 100644 --- a/rt/share/html/Search/Results.xls +++ b/rt/share/html/Search/Results.xls @@ -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 |