ZF-8497: DayOfYear set and get not consistent

Description

// create a date object using a known date $date = new Zend_Date('2009-11-14');

// create a 2nd date object using the setDayOfYear method $date2 = new Zend_Date(); $date2->setDayOfYear(317);

// Results should be equal given that 14th November 2009 is day 317 of the year // however as you can see the 2nd date object returns 316 return $date->get(Zend_Date::DAY_OF_YEAR) . ' ' . $date2->get(Zend_Date::DAY_OF_YEAR);

Comments

upon further investigation I believe user error is most likely issue here, not ZF ;) Please cancel and ignore

Closing as requested as 'not an issue'.

Reopening

Please don't close issues without reproduction. Even when it's not reproducable it could be in need of a better documentation.

After reproduction I see that your problem lies within time and timezone.

$date is set on the date alone... resulting into '2009-11-14T00:00:00+01:00'

$date2 is set to now including time and timezone... AFTERWARDS you set the day which result into '2009-11-13T23:02:16+01:00'

As you see, by taking the timezone and time into account these 2 dates are completly different. Still the calculation is CORRECT.

As help for others: When you think that something is wrong please DEBUG your date object. Look into the FAQ: http://framework.zend.com/wiki/display/… for details.