Subject: | Bug: Template::Plugin::Date date.format(0) returns today not 01/01/1970 |
Date: | Sat, 01 Sep 2012 20:03:13 +0100 |
To: | bug-Template-Toolkit [...] rt.cpan.org |
From: | David McKelvie <dmck [...] interactive.co.uk> |
In Template::Plugin::Date (Version 2.78)
date.format(0) returns todays date not 01/01/1970
i.e. there needs to be a difference between
date.format(0)
and
date.format()
===========================================
use Template::Plugin::Date;
print "Template::Plugin::Date::VERSION ", $Template::Plugin::Date::VERSION, "\n";
my $x = Template::Plugin::Date->new();
for my $d ( -3, -2 -1, 0 , 1, 2 , 3 ){
print $x->format($d),"\n";
}
===========================================
Version 2.78
00:59:57 01-Jan-1970
00:59:57 01-Jan-1970
19:52:55 01-Sep-2012
01:00:01 01-Jan-1970
01:00:02 01-Jan-1970
01:00:03 01-Jan-1970
============================================
Probably
sub format {
my $self = shift;
my $params = ref($_[$#_]) eq 'HASH' ? pop(@_) : { };
- my $time = shift(@_) || $params->{ time } || $self->{ time }
- || $self->now();
+ my $time = shift(@_) // ( $params->{ time } || $self->{ time }
+ || $self->now() );
my $format = @_ ? shift(@_)
: ($params->{ format } || $self->{ format } || $FORMAT);
David McKelvie