Bug 1751381

Summary: perl Time::Piece does not respect julian day
Product: Red Hat Enterprise Linux 7 Reporter: Ryan Mullett <rmullett>
Component: perlAssignee: Jitka Plesnikova <jplesnik>
Status: CLOSED ERRATA QA Contact: icesalov
Severity: medium Docs Contact: Lenka Špačková <lkuprova>
Priority: unspecified    
Version: 7.7CC: bnater, jorton, jplesnik, jreznik, pasik, ppisar
Target Milestone: rcKeywords: EasyFix, Patch, Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: perl-5.16.3-296.el7 Doc Type: Bug Fix
Doc Text:
.The `strptime()` method of the `Time::Piece` Perl module now correctly parses Julian dates The `Time::Piece` Perl module did not correctly parse a day of the year (`%j`) using the `strptime()` method. Consequently, Julian dates were parsed incorrectly. This bug has been fixed, and the `strptime()` method provided by the `Time::Piece` module now handles Julian dates properly.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-29 19:18:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1780579    
Attachments:
Description Flags
Fix day of year parsing none

Description Ryan Mullett 2019-09-11 21:05:24 UTC
Description of problem:


Version-Release number of selected component (if applicable):
RHEL 7.7
perl 5.16.3
Time::Piece 1.20_01

- Resolved upstream with this bug: 
  https://rt.cpan.org/Public/Bug/Display.html?id=88211

How reproducible:
Always

Steps to Reproduce:
1. sudo yum install perl-Time-Piece -y
2. perl -mTime::Piece -e 'print Time::Piece->strptime("2019 1", "%Y %j")->strftime("%c")'
3. perl -mTime::Piece -e 'print Time::Piece->strptime("2019 32", "%Y %j")->strftime("%c")'

Actual results:
Tue 01 Jan 2019 12:00:00 AM UTC
Tue 01 Jan 2019 12:00:00 AM UTC

Expected results:
Tue 01 Jan 2019 12:00:00 AM UTC
Fri 01 Feb 2019 12:00:00 AM UTC

Additional info:

Comment 2 Jitka Plesnikova 2019-09-12 08:20:59 UTC
Created attachment 1614383 [details]
Fix day of year parsing

Comment 3 Petr Pisar 2019-11-21 15:46:02 UTC
I confirm this issue in perl-Time-Piece-1.20.1-294.el7_6.

Comment 6 Jitka Plesnikova 2020-01-20 11:50:31 UTC
When I tried to build the patched perl, I found that tests ./cpan/Time-Local/t/Local.t failed with this error:

../cpan/Time-Local/t/Local.t ...................................... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/163 subtests 
	(less 11 skipped subtests: 150 okay)
#   Failed test 'timelocal year for 1970 1 2 0 0 0'
#   at t/Local.t line 108.
#          got: '170'
#     expected: '70'
#   Failed test 'timegm year for 1970 1 2 0 0 0'
#   at t/Local.t line 124.
#          got: '170'
#     expected: '70'
# Looks like you failed 2 tests of 163.


The issue is described in
https://github.com/Perl/perl5/issues/17410

The possible fix is provided here
https://rt.cpan.org/Public/Bug/Display.html?id=124787

I use the patch to solve a build failure.

Comment 14 errata-xmlrpc 2020-09-29 19:18:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (perl bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:3854