php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51987 Datetime fails to parse an ISO 8601 ordinal date (extended format)
Submitted: 2010-06-03 13:55 UTC Modified: 2022-05-13 13:10 UTC
Votes:3
Avg. Score:3.3 ± 1.2
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jbondc at openmv dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 7.1 OS: FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jbondc at openmv dot com
New email:
PHP Version: OS:

 

 [2010-06-03 13:55 UTC] jbondc at openmv dot com
Description:
------------
PHP 5.2.12 with Suhosin-Patch 0.9.7 (cli) (built: Dec 30 2009 15:41:26) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

Test script:
---------------
// Ordinal date — 12 April 1985

$d1 = new Datetime('1985102');
// OK

$d2 = new Datetime('1985-102');
// Exception: DateTime::__construct(): Failed to parse time string (1985-102) at position 7 (2): Unexpected character




Patches

Implementation_with_various_bug_fixes (last revision 2011-01-26 21:41 UTC by jbondc at openmv dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-03 14:36 UTC] salathe@php.net
-Status: Open +Status: Bogus
 [2010-06-03 14:36 UTC] salathe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Currently only YYdoy and YY.doy are supported. Adding in YY-doy would conflict 
with existing support for YY-mm. See http://php.net/datetime.formats for details 
of what is currently available.

(Key: YY = four-digit year, doy = day of year, mm = month number.)
 [2010-06-03 14:55 UTC] jbondc at openmv dot com
Please leave this bug open, I will look at submitting a patch.

There is no reason not to support:

$d2 = new Datetime('1985-001');
$d2 = new Datetime('1985-002');
...
$d2 = new Datetime('1985-365');

AND

$d2 = new Datetime('1985-01');
$d2 = new Datetime('1985-12');
 [2010-06-03 15:04 UTC] derick@php.net
-Status: Bogus +Status: Open -Type: Bug +Type: Feature/Change Request
 [2010-06-03 15:04 UTC] derick@php.net
It's a feature request though, *but* before we add it we must be certain that it doesn't conflict.
 [2010-06-03 15:38 UTC] salathe@php.net
Forgive my initial hastiness, I overlooked the fact that doy should always be 3-
digits in length. Sorry!!
 [2011-01-26 22:49 UTC] jbondc at openmv dot com
This patch needs:
re2c -d -b -o ext/date/lib/parse_date.c ext/date/lib/parse_date.re

It also fixes tests that were failing in trunk.

I changed the behavior of timelib_parse_from_format() to always initialized seconds, minutes, hours to 0 if they are not set.
 [2017-03-11 21:37 UTC] heiglandreas@php.net
-Assigned To: +Assigned To: derick
 [2017-03-11 21:37 UTC] heiglandreas@php.net
@derick Any chance we can merge this patch or close this as "Wont fix"?
 [2017-03-11 21:37 UTC] heiglandreas@php.net
-PHP Version: 5.2.13 +PHP Version: 7.1
 [2017-03-11 22:37 UTC] derick@php.net
patches to timelib need to have a PR made against:
https://github.com/derickr/timelib
 [2022-05-13 13:10 UTC] derick@php.net
-Status: Assigned +Status: Closed
 [2022-05-13 13:10 UTC] derick@php.net
Fixed in the through third party timelib library, for inclusion into PHP 8.1.7 (or PHP 8.1.8) and PHP 8.2 and later.
 [2022-05-20 12:25 UTC] git@php.net
Automatic comment on behalf of derickr
Revision: https://github.com/php/php-src/commit/78d5076b2572cc93ea50260b3de91586e97a4ee6
Log: Fixed bug #51987 (Datetime fails to parse an ISO 8601 ordinal date (extended format))
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 15:01:30 2024 UTC