|
Lines 16-26
package Koha::DateUtils;
Link Here
|
| 16 |
# Koha; if not, write to the Free Software Foundation, Inc., |
16 |
# Koha; if not, write to the Free Software Foundation, Inc., |
| 17 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
|
18 |
|
| 19 |
use strict; |
19 |
use Modern::Perl; |
| 20 |
use warnings; |
|
|
| 21 |
use 5.010; |
| 22 |
use DateTime; |
20 |
use DateTime; |
| 23 |
use C4::Context; |
21 |
use C4::Context; |
|
|
22 |
use Carp; |
| 24 |
|
23 |
|
| 25 |
use base 'Exporter'; |
24 |
use base 'Exporter'; |
| 26 |
use version; our $VERSION = qv('1.0.0'); |
25 |
use version; our $VERSION = qv('1.0.0'); |
|
Lines 189-197
should be returned without the time.
Link Here
|
| 189 |
|
188 |
|
| 190 |
sub output_pref { |
189 |
sub output_pref { |
| 191 |
my $params = shift; |
190 |
my $params = shift; |
| 192 |
my ( $dt, $force_pref, $force_time, $dateonly, $as_due_date ); |
191 |
my ( $dt, $str, $force_pref, $force_time, $dateonly, $as_due_date ); |
| 193 |
if ( ref $params eq 'HASH' ) { |
192 |
if ( ref $params eq 'HASH' ) { |
| 194 |
$dt = $params->{dt}; |
193 |
$dt = $params->{dt}; |
|
|
194 |
$str = $params->{str}; |
| 195 |
$force_pref = $params->{dateformat}; # if testing we want to override Context |
195 |
$force_pref = $params->{dateformat}; # if testing we want to override Context |
| 196 |
$force_time = $params->{timeformat}; |
196 |
$force_time = $params->{timeformat}; |
| 197 |
$dateonly = $params->{dateonly} || 0; # if you don't want the hours and minutes |
197 |
$dateonly = $params->{dateonly} || 0; # if you don't want the hours and minutes |
|
Lines 200-205
sub output_pref {
Link Here
|
| 200 |
$dt = $params; |
200 |
$dt = $params; |
| 201 |
} |
201 |
} |
| 202 |
|
202 |
|
|
|
203 |
carp "output_pref should not be called with both dt and str parameters" |
| 204 |
and return |
| 205 |
if $dt and $str; |
| 206 |
|
| 207 |
$dt = eval { dt_from_string( $str ) } if $str; |
| 208 |
|
| 203 |
return unless defined $dt; |
209 |
return unless defined $dt; |
| 204 |
|
210 |
|
| 205 |
# FIXME: see bug 13242 => no TZ for dates 'infinite' |
211 |
# FIXME: see bug 13242 => no TZ for dates 'infinite' |