Bugzilla – Attachment 65420 Details for
Bug 17699
DateTime durations are not correctly subtracted
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17699: Use limit as end_of_month
Bug-17699-Use-limit-as-endofmonth.patch (text/plain), 2.94 KB, created by
Marcel de Rooy
on 2017-08-02 12:04:50 UTC
(
hide
)
Description:
Bug 17699: Use limit as end_of_month
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-08-02 12:04:50 UTC
Size:
2.94 KB
patch
obsolete
>From f188b30c72bd7252db12828ea931f4ad3e949254 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 31 Jul 2017 11:03:37 -0300 >Subject: [PATCH] Bug 17699: Use limit as end_of_month >Content-Type: text/plain; charset=utf-8 > >From DateTime::Duration pod: >"" >For positive durations, the "end_of_month" parameter defaults to wrap. >For negative durations, the default is "limit". This should match how >most people "intuitively" expect datetime math to work. >"""" > >We need end_of_month => limit for positive durations as well. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Patron/Category.pm | 2 +- > t/db_dependent/Koha/Patrons.t | 10 +++++----- > 2 files changed, 6 insertions(+), 6 deletions(-) > >diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm >index 5a456b7..c96764b 100644 >--- a/Koha/Patron/Category.pm >+++ b/Koha/Patron/Category.pm >@@ -218,7 +218,7 @@ sub get_expiry_date { > if ( $self->enrolmentperiod ) { > $date ||= dt_from_string; > $date = dt_from_string( $date ) unless ref $date; >- return $date->add( months => $self->enrolmentperiod ); >+ return $date->add( months => $self->enrolmentperiod, end_of_month => 'limit' ); > } else { > return $self->enrolmentperioddate; > } >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index fc1a2bc..19aca2b 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -248,11 +248,11 @@ subtest 'renew_account' => sub { > for my $date ( '2016-03-31', '2016-11-30', dt_from_string() ) { > my $dt = dt_from_string( $date, 'iso' ); > Time::Fake->offset( $dt->epoch ); >- my $a_month_ago = $dt->clone->subtract( months => 1 )->truncate( to => 'day' ); >- my $a_year_later = $dt->clone->add( months => 12 )->truncate( to => 'day' ); >- my $a_year_later_minus_a_month = $dt->clone->add( months => 11 )->truncate( to => 'day' ); >- my $a_month_later = $dt->clone->add( months => 1 )->truncate( to => 'day' ); >- my $a_year_later_plus_a_month = $dt->clone->add( months => 13 )->truncate( to => 'day' ); >+ my $a_month_ago = $dt->clone->subtract( months => 1, end_of_month => 'limit' )->truncate( to => 'day' ); >+ my $a_year_later = $dt->clone->add( months => 12, end_of_month => 'limit' )->truncate( to => 'day' ); >+ my $a_year_later_minus_a_month = $dt->clone->add( months => 11, end_of_month => 'limit' )->truncate( to => 'day' ); >+ my $a_month_later = $dt->clone->add( months => 1 , end_of_month => 'limit' )->truncate( to => 'day' ); >+ my $a_year_later_plus_a_month = $dt->clone->add( months => 13, end_of_month => 'limit' )->truncate( to => 'day' ); > my $patron_category = $builder->build( > { source => 'Category', > value => { >-- >2.1.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 17699
:
57827
|
65358
|
65359
|
65360
|
65365
|
65366
|
65367
|
65369
|
65370
|
65371
|
65372
|
65400
|
65419
| 65420 |
65421
|
65422