Bugzilla – Attachment 13068 Details for
Bug 8966
Koha::Calendar::is_holiday truncates the date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8966 Koha::Calendar::is_holiday truncates the date
Bug-8966-KohaCalendarisholiday-truncates-the-date.patch (text/plain), 1.94 KB, created by
Tomás Cohen Arazi (tcohen)
on 2012-10-26 00:32:04 UTC
(
hide
)
Description:
Bug 8966 Koha::Calendar::is_holiday truncates the date
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2012-10-26 00:32:04 UTC
Size:
1.94 KB
patch
obsolete
>From 5a1a8e258a698f963dc5585b4d13367adf4f2115 Mon Sep 17 00:00:00 2001 >From: Maxime Pelletier <maxime.pelletier@libeo.com> >Date: Wed, 24 Oct 2012 17:22:02 -0400 >Subject: [PATCH] Bug 8966 Koha::Calendar::is_holiday truncates the date > >* Create a local copy of the date instead of calling truncate directly on the date >* Add a test to properly test that the issue is fixed > >Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> >--- > Koha/Calendar.pm | 9 +++++---- > t/Calendar.t | 6 +++++- > 2 files changed, 10 insertions(+), 5 deletions(-) > >diff --git a/Koha/Calendar.pm b/Koha/Calendar.pm >index 2a2e062..d4ea77e 100644 >--- a/Koha/Calendar.pm >+++ b/Koha/Calendar.pm >@@ -140,16 +140,17 @@ sub addDate { > > sub is_holiday { > my ( $self, $dt ) = @_; >- my $dow = $dt->day_of_week; >+ my $localdt = $dt->clone(); >+ my $dow = $localdt->day_of_week; > if ( $dow == 7 ) { > $dow = 0; > } > if ( $self->{weekly_closed_days}->[$dow] == 1 ) { > return 1; > } >- $dt->truncate( to => 'day' ); >- my $day = $dt->day; >- my $month = $dt->month; >+ $localdt->truncate( to => 'day' ); >+ my $day = $localdt->day; >+ my $month = $localdt->month; > if ( exists $self->{day_month_closed_days}->{$month}->{$day} ) { > return 1; > } >diff --git a/t/Calendar.t b/t/Calendar.t >index 7dc1f1b..80926eb 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -3,7 +3,7 @@ > use strict; > use warnings; > use DateTime; >-use Test::More tests => 21; >+use Test::More tests => 23; > use Koha::DateUtils; > > BEGIN { >@@ -103,6 +103,10 @@ $ret = $cal->addDate( $test_dt, 7, 'days' ); > cmp_ok( $ret->ymd(), 'eq', '2012-07-30', 'Add 7 days Days mode' ); > $cal->set_daysmode('Calendar'); > >+# see bugzilla #8966 >+is( $cal->is_holiday($later_dt), 0, 'is holiday for the next test' ); >+cmp_ok( $later_dt, 'eq', '2012-09-17T17:30:00', 'Date should be the same after is_holiday' ); >+ > # example tests for bug report > $cal->clear_weekly_closed_days(); > >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8966
:
13027
|
13028
| 13068