Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 893147 Details for
Bug 1095111
If truncate(to=>'week') fails, it will clobber the object
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Upstream fix ported to 1.06 and applicable to 1.04
DateTime-1.06-Don-t-leave-the-object-in-a-modified-state-after-a-f.patch (text/plain), 2.31 KB, created by
Petr Pisar
on 2014-05-07 07:56:02 UTC
(
hide
)
Description:
Upstream fix ported to 1.06 and applicable to 1.04
Filename:
MIME Type:
Creator:
Petr Pisar
Created:
2014-05-07 07:56:02 UTC
Size:
2.31 KB
patch
obsolete
>From d744bf17b7a0e0158eb813a8605cc0d8635f8959 Mon Sep 17 00:00:00 2001 >From: Dave Rolsky <autarch@urth.org> >Date: Sat, 3 May 2014 11:39:47 +0800 >Subject: [PATCH] Don't leave the object in a modified state after a failed > truncate( to => 'week' ) >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Petr Pisar: Ported to 1.06. > >Signed-off-by: Petr PÃsaÅ <ppisar@redhat.com> >--- > lib/DateTime.pm | 11 ++++++++++- > t/16truncate.t | 38 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 1 deletion(-) > >diff --git a/lib/DateTime.pm b/lib/DateTime.pm >index 1ff4c2e..a8663b2 100644 >--- a/lib/DateTime.pm >+++ b/lib/DateTime.pm >@@ -1985,7 +1985,16 @@ sub set_formatter { > $self->add( days => -1 * $day_diff ); > } > >- return $self->truncate( to => 'day' ); >+ # This can fail if the truncate ends up giving us an invalid local >+ # date time. If that happens we need to reverse the addition we >+ # just did. See https://rt.cpan.org/Ticket/Display.html?id=93347. >+ try { >+ $self->truncate( to => 'day' ); >+ } >+ catch { >+ $self->add( days => $day_diff ); >+ die $_; >+ }; > } > else { > my $truncate; >diff --git a/t/16truncate.t b/t/16truncate.t >index 0058f50..a478760 100644 >--- a/t/16truncate.t >+++ b/t/16truncate.t >@@ -5,6 +5,7 @@ use Test::Fatal; > use Test::More 0.88; > > use DateTime; >+use Try::Tiny; > > my %vals = ( > year => 50, >@@ -233,4 +234,41 @@ my %vals = ( > } > } > >+{ >+ my $dt = DateTime->new( >+ year => 2010, >+ month => 3, >+ day => 25, >+ hour => 1, >+ minute => 5, >+ time_zone => 'Asia/Tehran', >+ ); >+ >+ is( >+ $dt->day_of_week(), >+ 4, >+ 'day of week is Thursday' >+ ); >+ >+ my $error; >+ try { >+ $dt->truncate( to => 'week' ); >+ } >+ catch { >+ $error = $_; >+ }; >+ >+ like( >+ $error, >+ qr/Invalid local time for date/, >+ 'truncate operation threw an error because of an invalid local datetime' >+ ); >+ >+ is( >+ $dt->day_of_week(), >+ 4, >+ 'day of week does not change after failed truncate() call' >+ ); >+} >+ > done_testing(); >-- >1.9.0 >
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
Attachments on
bug 1095111
:
893144
| 893147