Lines 17-37
package Koha::Template::Plugin::KohaDates;
Link Here
|
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
17 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 |
|
19 |
|
20 |
use strict; |
20 |
use Modern::Perl; |
21 |
use warnings; |
|
|
22 |
|
21 |
|
23 |
use Template::Plugin::Filter; |
22 |
use Template::Plugin::Filter; |
24 |
use base qw( Template::Plugin::Filter ); |
23 |
use base qw( Template::Plugin::Filter ); |
25 |
use warnings; |
|
|
26 |
use strict; |
27 |
|
24 |
|
28 |
use C4::Dates; |
25 |
use Koha::DateUtils; |
|
|
26 |
our $DYNAMIC = 1; |
27 |
|
28 |
sub init { |
29 |
my $self = shift; |
30 |
$self->{ _DYNAMIC } = 1; |
31 |
return $self; |
32 |
} |
29 |
|
33 |
|
30 |
sub filter { |
34 |
sub filter { |
31 |
my ($self,$text) = @_; |
35 |
my ( $self, $text, $args, $config ) = @_; |
32 |
return "" if not $text; |
36 |
return "" unless $text; |
33 |
my $date = C4::Dates->new( $text, 'iso' ); |
37 |
$config->{with_hours} //= 0; |
34 |
return $date->output("syspref"); |
38 |
my $dt = dt_from_string( $text, 'iso' ); |
|
|
39 |
return output_pref( $dt, undef, !$config->{with_hours} ); |
35 |
} |
40 |
} |
36 |
|
41 |
|
37 |
1; |
42 |
1; |