use base 'Exporter';
use version; our $VERSION = qv('1.0.0');
-our @EXPORT = (qw( dt_from_string output_pref format_sqldatetime));
+our @EXPORT = (qw( dt_from_string output_pref format_sqldatetime output_pref_due ));
=head1 DateUtils
return;
}
+=head2 output_pref_due
+
+$date_string = output_pref_due($dt, [$format] );
+
+Returns a string containing the time & date formatted as per the C4::Context setting
+
+A second parameter allows overriding of the syspref value. This is for testing only
+In usage use the DateTime objects own methods for non standard formatting
+
+This is effectivelyt a wrapper around output_pref for due dates
+the time portion is stripped if it is '23:59'
+
+=cut
+
+sub output_pref_due {
+ my $disp_str = output_pref(@_);
+ $disp_str=~s/ 23:59//;
+ return $disp_str;
+}
+
=head2 format_sqldatetime
$string = format_sqldatetime( $string_as_returned_from_db );
$issue->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} );
$issue->{'description'} = $itemtypes->{$itemtype}->{'description'};
}
- $issue->{date_due} = output_pref($issue->{date_due});
+ $issue->{date_due} = output_pref_due($issue->{date_due});
push @issuedat, $issue;
$count++;
use DateTime::TimeZone;
use C4::Context;
-use Test::More tests => 21; # last test to print
+use Test::More tests => 23;
BEGIN { use_ok('Koha::DateUtils'); }
$date_string = output_pref( $dt, 'metric' );
cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'metric output';
+$date_string = output_pref_due( $dt, 'metric' );
+cmp_ok $date_string, 'eq', '16/06/2011 12:00', 'output_pref_due preserves non midnight HH:SS';
+
+$dt->set_hour(23);
+$dt->set_minute(59);
+$date_string = output_pref_due( $dt, 'metric' );
+cmp_ok $date_string, 'eq', '16/06/2011', 'output_pref_due truncates HH:SS at midnight';
+
my $dear_dirty_dublin = DateTime::TimeZone->new( name => 'Europe/Dublin' );
my $new_dt = dt_from_string( '16/06/2011', 'metric', $dear_dirty_dublin );
isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' );