includes/functions.php
changeset 1159 a1cca4472a58
parent 1133 6e51ca5e29eb
child 1167 3c73e1b6d33f
equal deleted inserted replaced
1158:e733f984c990 1159:a1cca4472a58
   346   // it's gonna be in minutes, so multiply by 60 to offset the unix timestamp
   346   // it's gonna be in minutes, so multiply by 60 to offset the unix timestamp
   347   $timestamp = $timestamp + ( $timezone * 60 );
   347   $timestamp = $timestamp + ( $timezone * 60 );
   348   
   348   
   349   // are we in DST?
   349   // are we in DST?
   350   global $dst_params;
   350   global $dst_params;
       
   351   $dst_offset = 0;
   351   if ( check_timestamp_dst($timestamp, $dst_params[0], $dst_params[1], $dst_params[2], $dst_params[3]) )
   352   if ( check_timestamp_dst($timestamp, $dst_params[0], $dst_params[1], $dst_params[2], $dst_params[3]) )
   352   {
   353   {
   353     // offset for DST
   354     // offset for DST
   354     $timestamp += ( $dst_params[4] * 60 );
   355     $timestamp += ( $dst_params[4] * 60 );
       
   356     $dst_offset = $dst_params[4];
       
   357   }
       
   358   
       
   359   // Does this date string include a timezone? If so, gmdate() will report UTC, which is wrong
       
   360   // FIXME This is kind of a halfass replacement...
       
   361   foreach ( array('e', 'T', 'O', 'P') as $char )
       
   362   {
       
   363     if ( ($pos = strpos($string, $char)) !== false )
       
   364     {
       
   365       if ( $string{ $pos - 1 } != '\\' )
       
   366       {
       
   367         // add in our own timezone string
       
   368         // FIXME: l10n? (do we need to? does anyone really not know what "GMT" means? even uglier escaping?)
       
   369         $tzi = '\\G\\M\\T';
       
   370         $tzo = $timezone + $dst_offset;
       
   371         $sign = $tzo > 0 ? '+' : '-';
       
   372         $tzi .= $sign . (intval(abs($tzo / 60)));
       
   373         if ( $tzo % 60 )
       
   374           $tzi .= sprintf(":%02d", abs($tzo) % 60);
       
   375         
       
   376         $string = substr($string, 0, $pos) . $tzi . substr($string, $pos + 1);
       
   377       }
       
   378     }
   355   }
   379   }
   356   
   380   
   357   // Let PHP do the work for us =)
   381   // Let PHP do the work for us =)
   358   $result = gmdate($string, $timestamp);
   382   $result = gmdate($string, $timestamp);
   359   if ( isset($relative_date) )
   383   if ( isset($relative_date) )