#51030 [Opn]: DateInterval::format() does not handle "carry-over points"

From: Date: Sat, 13 Feb 2010 12:54:04 +0000
Subject: #51030 [Opn]: DateInterval::format() does not handle "carry-over points"
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3884@lists.php.net to get a copy of this message
ID: 51030 User updated by: m dot kurzyna at crystalpoint dot pl Reported By: m dot kurzyna at crystalpoint dot pl Status: Open Bug Type: Documentation problem Operating System: Linux PHP Version: Irrelevant New Comment: Aye. And i admit i haven't thought of that - feel free to mark me bogus ;-) Leap years also come to mind now; as i was fixed on the time issue which i have run into i haven't considered dates at all. I'd still vote on documentation clarification there though; and maybe giving your explanation as well. As a side note - i was experimenting with date manipulation (in order to check whether combination of DateTime::add()/diff() would yield what i need) and have run into another (sort of) ambiguity: $today = new DateTime(); $tomorrow = $today ->add(new DateInterval('P1D'); $today is $tomorrow (as in same object). I didn't expect that only by examining documentation. I'd change: Return Values Returns the modified DateTime. to: Return Values Returns the modified self object (DateTime). I love the ability to do chain calls and actually like this feature - it's just i haven't expected it from core. No real statistics behind it but i have a feeling that most PHP functions don't return self references. Take SimpleXMLElement::addChild() for example as it's a similar case. It returns added child not "self" containing the added child. No matter - just wondering off there. Point is: please be so kind and consider documentation enhancements (although i admit it's not a very critical case and based mostly on my assumptions on how things will work). Previous Comments: ------------------------------------------------------------------------ [2010-02-12 20:39:36] derick@php.net THis is (code wise) on purpose, because you can't really overflow "32 days" for example (it could be 1month, 4 days to 1 month, 1 days f.e.) ------------------------------------------------------------------------ [2010-02-12 20:02:07] m dot kurzyna at crystalpoint dot pl Description: ------------ DateInterval::format() does not handle "carry over points" thus having 25 hours or 70 minutes is a valid output. Format description suggests that output would be recalculated (but specifying min,middle,max sample outputs). Submitted as documentation problem but IMHO the implementation could be changed (at least be optional whether to recalculate carry overs or not). Reproduce code: --------------- <?php $dti = new \DateInterval('PT70M'); echo $dti->format('%H:%I:%S'); ?> Expected result: ---------------- 01:10:00 Actual result: -------------- 00:70:00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=51030&edit=1

« previous php.doc.bugs (#3884) next »