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: 2017-03-11 22:37 UTC
Votes:2
Avg. Score:3.5 ± 1.5
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: Assigned Package: Date/time related
PHP Version: 7.1 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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)

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC