Ответы пользователя по тегу PHP
  • Drupal 6 — jQuery Timer не правильно считает?

    Ziklon
    @Ziklon Автор вопроса
    Нашёл кусок кода в template.php, видимо тут какая то ошибка.
    <code>//функция генерит разметку для таймера.
    function theme_timer ($time_to_event) {
    
      $time = $time_to_event - time();
    
      $timer = array();
    
      $timer['days'] = floor($time / (60 * 60 * 24));
      
      $timer['hours'] = floor(($time - $timer['days'] * 60 * 60 * 24) / (60 * 60));
      $timer['minutes'] = floor(($time - $timer['days'] * 60 * 60 * 24 - $timer['hours'] * 60 * 60) / 60);
      /*
      if(!drupal_is_front_page()) { //закоментить после установки главной
        $timer['second'] = $time - $timer['days'] * 60 * 60 * 24 - $timer['hours'] * 60 * 60 - $timer['minutes'] * 60;
      }
      */
      $time_part_output = array();
      foreach ($timer as $part => $int) {
        if(strlen($int) < 2) {
          $timer[$part] = '0' . $int;
        }
        
        if ( in_array($part, array('hours', 'minutes', 'second')) ) {
         $letter_line = ''; 
        }
        else {
          $letter_line =  '<span class="letter-line ">';
        }
        
        foreach (str_split($timer[$part]) as $key => $symvol) {
          $time_part_output[$part] .= '<span class="letter-wrapper">' . $letter_line . '</span><span class="letter letter-' . $part . ' int_' . $key . '">' . $symvol . '</span></span>';
        }
        
      }
      /*
        if(!drupal_is_front_page()) { 
        return $time_part_output['days'] .
             $time_part_output['hours'] . '<span class="to_dot"> : </span>' .
             $time_part_output['minutes'] . '<span class="to_dot"> : </span>' .
             $time_part_output['second'];
       }
      */
        return $time_part_output['days'].
             $time_part_output['hours'] .
             $time_part_output['minutes'] .
             $time_part_output['second'];
      
    }
    
    /*ФУНКЦИИ ВОЗВРАЩАЮТ РАЗМЕТКУ ЗАГОЛОВКА СТРАНИЦЫ*/
    </code>
    Ответ написан
    Комментировать