Changeset 3118 for branches/2.0/include


Ignore:
Timestamp:
Jan 31, 2009, 2:12:20 AM (16 years ago)
Author:
rvelices
Message:

merge r3117 from trunk:

  • fix use $pagenb_image_page instead of $user... when creating the nav bar (same as category_default)
  • rewrote function format_date without regular expressions (faster); parameter date type is not used anymore (but I left it there for now)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/include/functions.inc.php

    r3046 r3118  
    579579  global $lang;
    580580
    581   list($year,$month,$day,$hour,$minute,$second) = array(0,0,0,0,0,0);
    582 
    583   switch ( $type )
    584   {
    585     case 'us' :
    586     {
    587       list($year,$month,$day) = explode('-', $date);
    588       break;
    589     }
    590     case 'unix' :
    591     {
    592       list($year,$month,$day,$hour,$minute) =
    593         explode('.', date('Y.n.j.G.i', $date));
    594       break;
    595     }
    596     case 'mysql_datetime' :
    597     {
    598       preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/',
    599                  $date, $out);
    600       list($year,$month,$day,$hour,$minute,$second) =
    601         array($out[1],$out[2],$out[3],$out[4],$out[5],$out[6]);
    602       break;
    603     }
    604     case 'mysql_date' :
    605     {
    606       preg_match('/^(\d{4})-(\d{2})-(\d{2})$/',
    607                  $date, $out);
    608       list($year,$month,$day) =
    609         array($out[1],$out[2],$out[3]);
    610       break;
    611     }
    612   }
     581  $ymdhms = array();
     582  $tok = strtok( $date, '- :');
     583  while ($tok !== false)
     584  {
     585    $ymdhms[] = $tok;
     586    $tok = strtok('- :');
     587  }
     588
     589  if ( count($ymdhms)<3 )
     590  {
     591    return false;
     592  }
     593
    613594  $formated_date = '';
    614595  // before 1970, Microsoft Windows can't mktime
    615   if ($year >= 1970)
     596  if ($ymdhms[0] >= 1970)
    616597  {
    617598    // we ask midday because Windows think it's prior to midnight with a
    618599    // zero and refuse to work
    619     $formated_date.= $lang['day'][date('w', mktime(12,0,0,$month,$day,$year))];
    620   }
    621   $formated_date.= ' '.$day;
    622   $formated_date.= ' '.$lang['month'][(int)$month];
    623   $formated_date.= ' '.$year;
    624   if ($show_time)
    625   {
    626     $formated_date.= ' '.$hour.':'.$minute;
    627   }
    628 
     600    $formated_date.= $lang['day'][date('w', mktime(12,0,0,$ymdhms[1],$ymdhms[2],$ymdhms[0]))];
     601  }
     602  $formated_date.= ' '.$ymdhms[2];
     603  $formated_date.= ' '.$lang['month'][(int)$ymdhms[1]];
     604  $formated_date.= ' '.$ymdhms[0];
     605  if ($show_time and count($ymdhms)>=5 )
     606  {
     607    $formated_date.= ' '.$ymdhms[3].':'.$ymdhms[4];
     608  }
    629609  return $formated_date;
    630610}
Note: See TracChangeset for help on using the changeset viewer.