Bugzilla – Attachment 57827 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: Fix negative duration calculations in tests
Bug-17699-Fix-negative-duration-calculations-in-te.patch (text/plain), 1.55 KB, created by
Jonathan Druart
on 2016-11-30 08:11:58 UTC
(
hide
)
Description:
Bug 17699: Fix negative duration calculations in tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-11-30 08:11:58 UTC
Size:
1.55 KB
patch
obsolete
>From 95814159bbc31d63a45d3256d2efa0145baca1cd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 30 Nov 2016 08:09:36 +0000 >Subject: [PATCH] Bug 17699: Fix negative duration calculations in tests > >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. >""" > >Today we are Nov 30, that means $today->subtract( months => 1 ) will return Oct 31, >when we usually expect Oct 30 in tests > >Test plan: > prove t/db_dependent/Koha/Patrons.t >should return green >--- > t/db_dependent/Koha/Patrons.t | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 7be731c..0723346 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -192,7 +192,7 @@ subtest 'is_expired' => sub { > > subtest 'renew_account' => sub { > plan tests => 10; >- my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); >+ my $a_month_ago = dt_from_string->subtract( months => 1, end_of_month => 'wrap' )->truncate( to => 'day' ); > my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); > my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' ); > my $a_month_later = dt_from_string->add( months => 1 )->truncate( to => 'day' ); >-- >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