Issue Type: Improvement Created: 2008-03-27T05:53:06.000+0000 Last Updated: 2008-09-02T10:39:13.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)
Reporter: Karol Grecki (antych) Assignee: Thomas Weidner (thomas) Tags: - Zend_Date
Related issues: Attachments: - cachegrind.out.4219244990.tar.gz
I was profiling my app and noticed what looks like an excessive number of calls to this function.
This simple code results in 4018 calls to isYearLeapYear()
<pre class="highlight"> $s = new Zend_Date('311207', 'ddMMyy'); $e = new Zend_Date('090108', 'ddMMyy'); $s->compareDate($e);
I'm raising this just in case a mistake was made. Could be no issue.
Posted by Thomas Weidner (thomas) on 2008-03-27T10:47:02.000+0000
No this is NO problem or bug or mistake.
You entered the date "31.December. 7 after Christ"... the year 0007 and not 2007. Now the timestamp is calculated for the year where christ was 7 years old.
PHP can only handle dates until 1914. (negative timestamps). Zend_Date builds the timestamp for this date himself. The calculation for real historical or even astronomical dates is complicated and is done mathematically where the mentioned function is one part of this process.
When you look into the manual there is a sentence about "historical" or "astronomical" dates and performance.
Posted by Karol Grecki (antych) on 2008-03-27T11:08:40.000+0000
Actually I entered the year 2007 as 07 and it was parsed as I expcected
<pre class="highlight"> $s = new Zend_Date('311207', 'ddMMyy'); echo $s; //31 Dec 2007 00:00:00
Also after changing code to
<pre class="highlight"> $s = new Zend_Date('31122007', 'ddMMyyyy'); $e = new Zend_Date('09012008', 'ddMMyyyy'); $s->compareDate($e);
isYearLeapYear() is still called over 4000 times
Posted by Thomas Weidner (thomas) on 2008-03-27T11:12:50.000+0000
Posted by Thomas Weidner (thomas) on 2008-03-27T11:48:55.000+0000
Fixed with SVN-9066... is 0 times called better for you ? ;-)
Posted by Karol Grecki (antych) on 2008-03-27T11:57:46.000+0000
Nice one, cheers
Posted by Wil Sinclair (wil) on 2008-09-02T10:39:13.000+0000
Updating for the 1.6.0 release.
Have you found an issue?
See the Overview section for more details.