Bugzilla – Attachment 33589 Details for
Bug 13242
Slow checkin for patrons restricted indefinitely
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13242: Add a UT to t/DateUtils.t for testing DateTime bug
Bug-13242-Add-a-UT-to-tDateUtilst-for-testing-Date.patch (text/plain), 2.68 KB, created by
Frédéric Demians
on 2014-11-15 12:16:34 UTC
(
hide
)
Description:
Bug 13242: Add a UT to t/DateUtils.t for testing DateTime bug
Filename:
MIME Type:
Creator:
Frédéric Demians
Created:
2014-11-15 12:16:34 UTC
Size:
2.68 KB
patch
obsolete
>From 46d5acf18d190732131ff4a8cb53106538b744be Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= <f.demians@tamil.fr> >Date: Sat, 15 Nov 2014 13:20:31 +0100 >Subject: [PATCH] Bug 13242: Add a UT to t/DateUtils.t for testing DateTime bug > >A bug in DateTime slow down drastically date parsing when the dates are in the >far distant future: > >https://metacpan.org/pod/DateTime#Determining-the-Local-Time-Zone-Can-Be-Slow > >This UT tests this situation which affects Koha::DateUtils function >dt_from_string() and output_pref(). > >TO TEST: >- Apply the patch containing the UT >- prove -v t/DateUtils.t >- You see that parsing a 9999-01-01 that take forever (ie more than 1s) >- Apply the patch containing the fix >- prove -v t/DateUtils.t >- No more complain. >--- > t/DateUtils.t | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > >diff --git a/t/DateUtils.t b/t/DateUtils.t >index 9afddc1..2439127 100755 >--- a/t/DateUtils.t >+++ b/t/DateUtils.t >@@ -1,12 +1,11 @@ >-use strict; >-use warnings; >-use 5.010; >+use Modern::Perl; > use DateTime; > use DateTime::TimeZone; > > use C4::Context; >-use Test::More tests => 34; >+use Test::More tests => 41; > use Test::MockModule; >+use Time::HiRes qw/ gettimeofday /; > > BEGIN { use_ok('Koha::DateUtils'); } > >@@ -77,6 +76,17 @@ isa_ok( $new_dt, 'DateTime', 'Create DateTime with different timezone' ); > cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, > 'Returned Dublin object matches input' ); > >+for ( qw/ 2014-01-01 2100-01-01 9999-01-01 / ) { >+ my $duration = gettimeofday(); >+ $new_dt = dt_from_string($_, 'iso', $dear_dirty_dublin); >+ $duration = gettimeofday() - $duration; >+ cmp_ok $duration, '<', 1, "Create DateTime with dt_from_string() for $_ with TZ in less than 1s"; >+ $duration = gettimeofday(); >+ output_pref( { dt => $new_dt } ); >+ $duration = gettimeofday() - $duration; >+ cmp_ok $duration, '<', 1, "Create DateTime with output_pref() for $_ with TZ in less than 1s"; >+} >+ > $new_dt = dt_from_string( '2011-06-16 12:00', 'sql' ); > isa_ok( $new_dt, 'DateTime', 'Create DateTime from (mysql) sql' ); > cmp_ok( $new_dt->ymd(), 'eq', $testdate_iso, 'sql returns correct date' ); >@@ -106,6 +116,10 @@ cmp_ok( $dt0->ymd(), 'eq', $ymd, 'Returned object corrects iso day 0' ); > $dt0 = dt_from_string( '0000-00-00', 'iso' ); > is( $dt0, undef, "undefined returned for 0 iso date" ); > >+# Return undef if passed mysql 9999-* date >+my $dt9999 = dt_from_string( '9999-12-31' ); >+is( $dt9999->ymd(), '9999-12-31', "dt_from_string should return a DateTime object for 9999-12-31" ); >+ > my $formatted = format_sqldatetime( '2011-06-16 12:00:07', 'metric', '24hr' ); > cmp_ok( $formatted, 'eq', '16/06/2011 12:00', 'format_sqldatetime conversion' ); > >-- >2.1.2
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 13242
:
33510
|
33511
|
33560
|
33561
|
33564
|
33565
|
33589
|
33590
|
33591
|
33592
|
33596
|
33597
|
33945