#957: AgaviTranslationManager::createCalendar() forgets TZ offset when called
with DateTime object
-------------------------+--------------------------------------------------
 Reporter:  felix        |       Owner:  dominik                                
                     
     Type:  defect       |      Status:  new                                    
                     
 Priority:  normal       |   Milestone:  0.11.6                                 
                     
Component:  translation  |     Version:  0.11.5                                 
                     
 Severity:  normal       |    Keywords:  TranslationManager createCalendar 
Calendar DateTime Timezone
Has_patch:  0            |  
-------------------------+--------------------------------------------------

Comment(by felix):

 The problem originates in the fact that DateTimezone->getName() only
 returns the offset while AgaviTimezone::createCustomTimezone() expects
 GMT+offset.

 The following minipatch solves the problem:

 {{{
 Index:
 
/Users/fgilcher/Sites/agavi/branches/1.0/src/translation/AgaviTranslationManager.class.php
 ===================================================================
 ---
 
/Users/fgilcher/Sites/agavi/branches/1.0/src/translation/AgaviTranslationManager.class.php
 (Revision 3421)
 +++
 
/Users/fgilcher/Sites/agavi/branches/1.0/src/translation/AgaviTranslationManager.class.php
 (Arbeitskopie)
 @@ -899,7 +899,11 @@
                 }

                 if($time instanceof DateTime) {
 -
 $c->setTimeZone($this->createTimeZone($time->getTimezone()->getName()));
 +                       $tzName = $time->getTimezone()->getName();
 +                       if(preg_match('/^[+-0-9]/', $tzName)) {
 +                               $tzName = 'GMT' . $tzName;
 +                       }
 +                       $c->setTimeZone($this->createTimeZone($tzName));
                         $dateStr = $time->format('Y z G i s');
                         list($year, $doy, $hour, $minute, $second) =
 explode(' ', $dateStr);
                         $c->set(AgaviDateDefinitions::YEAR, $year);


 }}}

-- 
Ticket URL: <http://trac.agavi.org/ticket/957#comment:3>
Agavi <http://www.agavi.org/>
An MVC Framework for PHP5


_______________________________________________
Agavi Tickets Mailing List
[email protected]
http://lists.agavi.org/mailman/listinfo/tickets

Reply via email to