Bug 5549 : Don't confuse the users with an irrelevant time
[koha.git] / t / DateUtils.t
index 9569cfe..82d499f 100755 (executable)
@@ -5,7 +5,7 @@ use DateTime;
 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'); }
 
@@ -33,6 +33,14 @@ cmp_ok $date_string, 'eq', '06/16/2011 12:00', 'us output';
 $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' );