Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.2

Bug #3330 Time elements from mysql are not working due to date parsing problem
Submitted: 2005-01-30 16:37 UTC
From: abarrei at gmail dot com Assigned: justinpatrin
Status: No Feedback Package: DB_DataObject_FormBuilder
PHP Version: 4.3.8 OS: Unix
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 4 + 2 = ?

 
 [2005-01-30 16:37 UTC] abarrei at gmail dot com
Description: ------------ Mysql select for time fields returns the time in the folowing format: HH:mm:ss Example 11:00:00. I looked through through the Formbuilder.php and I found you use the Date Package for the _date2array callback function and its conversion. This package receives and ISO 8601, and as an only time string is not compliant with that standard, the Date objects returns empty. * @version $Id: FormBuilder.php,v 1.119 2005/01/28 01:23:45 justinpatrin Exp $ I add the following line to the _date2array function below line 1864 // Convert to ISO 8601 format // Specialy time objects $date = strftime("%Y-%m-%dT%T",strtotime($date)); I think its a nice fix, becouse it wouldn't mess with the other types, but I haven't thought too much about any side effects though. I also noticed that the _array2date function you provide is not behaving normally. THus, you have these if clauses: if (isset($year) && isset($month) && isset($dateInput['d'])) { and if (isset($hour) && isset($dateInput['i']) && isset($dateInput['s'])) { so you expect the all year, months and dates exist for building the date string, and that all hours, minutes, and seconds exists for building the time string. As dateFormatElement and timeFormatElement let you lack of any of those fields, for example: $timeFormatElement = "H:i" It would be nice to have that function expect that and build the date with a default value (seconds=0) for example, becouse if not, the string is empty and a value of 0 is inserted into the database. I fix that function to, only the part of the time, that is what I am needing right now, I did the following fix in the if clause of the time part: if (isset($hour) && isset($dateInput['i'])) { if (!empty($strDate)) { $strDate .= ' '; } $strDate .= $hour.':'.$dateInput['i']; if (isset($dateInput['s'])) { $strDate .= ':'.$dateInput['s']; } if (isset($ampm)) { $strDate .= ' '.$ampm; } } of course I am still expecting and $hour and minuts from the time object. I know this can be overriden but I would be nice to have it fixed on the package. Let me know what you think and If I have the time when I finished what I need to finish right now I can give you a more complete array2date following this needs, if you think they are worth it. Reproduce code: --------------- N/A Expected result: ---------------- N/A Actual result: -------------- N/A

Comments

 [2005-01-30 16:51 UTC] abarrei at gmail dot com
A different _array2date function with the defaults values I was talking about. What do you think? function _array2date($dateInput, $timestamp = false) { if (isset($dateInput['M'])) { $month = $dateInput['M']; } elseif (isset($dateInput['m'])) { $month = $dateInput['m']; } elseif (isset($dateInput['F'])) { $month = $dateInput['F']; } if (isset($dateInput['Y'])) { $year = $dateInput['Y']; } elseif (isset($dateInput['y'])) { $year = $dateInput['y']; } if (isset($dateInput['H'])) { $hour = $dateInput['H']; } elseif (isset($dateInput['h'])) { $hour = $dateInput['h']; } if (isset($dateInput['a'])) { $ampm = $dateInput['a']; } elseif (isset($dateInput['A'])) { $ampm = isset($dateInput['A']); } $strDate = sprintf( "%04d-%02d-%02d %02d:%02d:%02d%s", isset($year) ? $year : 0 , isset($month) ? $month : 0 , isset($dateInput['d']) ? $dateInput['d'] : 0 , isset($hour) ? $hour : 0 , isset($dateInput['i']) ? $dateInput['i'] : 0 , isset($dateInput['s']) ? $dateInput['s'] : 0 , isset($ampm) ? " ".$ampm : "" ); //$this->debug('<i>_array2date():</i> to '.$strDate.' ...'); return $strDate; }
 [2005-02-02 19:30 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!