[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/inc/libs/ -> lib.date.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  class dt
  24  {
  25  	function str($p,$ts=NULL)
  26      {
  27          if ($ts == NULL) { $ts = time(); }
  28          
  29          $hash = '799b4e471dc78154865706469d23d512';
  30          $p = preg_replace('/(?<!%)%(a|A)/','{{'.$hash.'__$1%w__}}',$p);
  31          $p = preg_replace('/(?<!%)%(b|B)/','{{'.$hash.'__$1%m__}}',$p);
  32          
  33          $res = strftime($p,$ts);
  34          
  35          $res = preg_replace_callback('/{{'.$hash.'__(a|A|b|B)([0-9]{1,2})__}}/',array('dt','_callback'),$res);
  36          
  37          return $res;
  38      }
  39      
  40  	function dt2str($p,$dt)
  41      {
  42          return dt::str($p,strtotime($dt));
  43      }
  44      
  45  	function iso8601($ts)
  46      {
  47          $tz = date('O',$ts);
  48          $tz = substr($tz,0,-2).':'.substr($tz,-2);
  49          return date('Y-m-d\\TH:i:s',$ts).$tz;
  50      }
  51      
  52  	function _callback($args)
  53      {
  54          $b = array(1=>'Jan',2=>'Feb',3=>'Mar',4=>'Apr',5=>'May',6=>'Jun',
  55          7=>'Jul',8=>'Aug',9=>'Sep',10=>'Oct',11=>'Nov',12=>'Dec');
  56          
  57          $B = array(1=>'January',2=>'February',3=>'March',4=>'April',
  58          5=>'May',6=>'June',7=>'July',8=>'August',9=>'September',
  59          10=>'October',11=>'November',12=>'December');
  60          
  61          $a = array(1=>'Mon',2=>'Tue',3=>'Wed',4=>'Thu',5=>'Fri',
  62          6=>'Sat',0=>'Sun');
  63          
  64          $A = array(1=>'Monday',2=>'Tuesday',3=>'Wednesday',4=>'Thursday',
  65          5=>'Friday',6=>'Saturday',0=>'Sunday');
  66          
  67          return __(${$args[1]}[(integer) $args[2]]);
  68      }
  69  }
  70  
  71  ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7