Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2008, 04:50 PM
Junior Member
 
Join Date: May 2008
Posts: 4
Default Zend_Date bug?

hello,

there is a strange behaviour of Zend_Date...

Code:
$date1 = array('year' => '2008', 'month' =>'4', 'day' =>'13', 'hour' => '10', 'minute' =>'45', 'second' => '12');
$show_date1 = new Zend_Date($date1);
echo $show_date1;

//returns: 2008-04-13 10:45:12
but
Code:
$date2 = array('year' => '2008', 'month' =>'4', 'day' =>'13', 'hour' => '23', 'minute' =>'45', 'second' => '12');
$show_date2 = new Zend_Date($date2);
echo $show_date2;

//returns: 2008-04-14 23:45:12
if 'hour' >= '22'
'day' = 'day' + 1

can anyone tell me something about this?

Code:
echo Zend_Version::VERSION;

//returns: 1.5.1
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-08-2008, 12:57 PM
Junior Member
 
Join Date: Jan 2008
Posts: 1
Default

Hi!

I know this doen't help but I have the same problem. I just can't find the code anymore. I had to subtract one hour to get to correct date. Zend_Date is a monster!

I think my problem was, that I reused the same Zend_Date object (which isn't the case in your example) and forgot to level the time correctly.

When I find my code I'll post it here.

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-12-2008, 06:53 PM
Ewok's Avatar
Junior Member
 
Join Date: Mar 2008
Location: Colorado SPrings
Posts: 16
Send a message via MSN to Ewok Send a message via Yahoo to Ewok
Default

Yet more unhelpfulness. I was calculating the last day of the month, so I picked the first day added a month and subtracted a day. Unless the month had 31 days, it would return the day as 32.

I changed tack and used the MONTH_DAYS instead, which works better for what I need, but If I needed to calculate yesterday from the start of a month, no worky.

Framework was version 1.5 when I tried it.
__________________
Give all victory and gain to others
Take all defeat and loss upon yourself
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-04-2008, 06:22 PM
Member
 
Join Date: Aug 2008
Posts: 55
Default

@wudz: Your problem is the timezone in addition with the array syntax. This has been fixed in the latest release.

@thedave: reusing a object you need to give a complete date first before doing any calculations

@ewok: Your end-of-month calculation can not work. When adding a month with different daylengths you will have eighter the 31 of the same month or the 1st of the next month... february will brake also all. Just doing a little basic math will show that this can not work as you want.

This can be done by adding 1 month, setting 1st of month, substract one day... all oter ways will not work properly.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-18-2008, 01:33 PM
Junior Member
 
Join Date: Aug 2008
Posts: 3
Red face I've got a similar problem

Hi all,

I've got a similar problem (but I don't know if it's linked to i18n) :

When I try to display the 29th december 2008 I got the 29th december 2009.

The code:
PHP Code:
$dayDate Zend_Date::now();
$dayDate->setYear(2008);
$dayDate->setMonth(12);
$dayDate->setDay(29);
echo 
$dayDate->toString('dd/MM/YYYY'); 
result = 29/12/2009

Strange ...

ZF version : 1.5.3
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-18-2008, 02:07 PM
Junior Member
 
Join Date: Aug 2008
Posts: 3
Default

I got the same problem with the 2007-12-31

Any idea ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-18-2008, 02:58 PM
Member
 
Join Date: Aug 2008
Posts: 55
Default

This is no bug but a feature.

You should read the manual where you find a description of this problem and the reason as also the solution.

Zend Framework: Documentation

From the manual:
Quote:
NoteNote that the default ISO format differs from PHP's format which can be irritating if you have not used in previous. Especially the format specifiers for Year and Minute are often not used in the intended way.

For year there are two specifiers available which are often mistaken. The Y specifier for the ISO year and the y specifier for the real year. The difference is small but significant. Y calculates the ISO year, which is often used for calendar formats. See for example the 31. December 2007. The real year is 2007, but it is the first day of the first week in the week 1 of the year 2008. So, if you are using 'dd.MM.yyyy' you will get '31.December.2007' but if you use 'dd.MM.YYYY' you will get '31.December.2008'. As you see this is no bug but a expected behaviour depending on the used specifiers.

For minute the difference is not so big. ISO uses the specifier m for the minute, unlike PHP which uses i. So if you are getting no minute in your format check if you have used the right specifier.
Simply said use "y" instead of "Y".
Sometimes reading the manual really helps.
__________________
Greetings
Thomas Weidner
I18N Team Leader, Zend Framework
http://www.thomasweidner.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-18-2008, 03:16 PM
Junior Member
 
Join Date: Aug 2008
Posts: 3
Default

Thanks a lot for your prompt response. You save me!

I'll read the doc until the end next time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:17 PM.