[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/tests/cases/tags/core/ -> WactDateFilterTest.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  class WactDateFilterTest extends WactTemplateTestCase
  11  {
  12      function testSimpleUse()
  13      {
  14        $template = '{$test|date:"Ymd"}';
  15        $this->registerTestingTemplate('/filters/core/date/var.html', $template);
  16  
  17        $page = $this->initTemplate('/filters/core/date/var.html');
  18        $page->set('test', mktime(0,0,0,date('m'),date('d'),date('y')));
  19        $output = $page->capture();
  20        $this->assertEqual($output, strftime('%Y%m%d'));
  21      }
  22  
  23  }
  24  
  25  class WactToDateFilterTestCase extends WactTemplateTestCase {
  26  
  27      function testSimpleUse() {
  28          $template = '{$test|todate}';
  29          $this->registerTestingTemplate('/filters/core/todate/var.html', $template);
  30  
  31          $page = $this->initTemplate('/filters/core/todate/var.html');
  32          $page->set('test', 'April 3, 1970');
  33          $output = $page->capture();
  34          $check = mktime(0,0,0,4,3,1970);
  35          $this->assertEqual($output, $check);
  36      }
  37  
  38    function testEmptyDate() {
  39          $template = '{$test|todate}';
  40          $this->registerTestingTemplate('/filters/core/todate/empty_date.html', $template);
  41  
  42          $page = $this->initTemplate('/filters/core/todate/empty_date.html');
  43          $output = $page->capture();
  44          $this->assertEqual($output, '');
  45    }
  46  
  47  }
  48  
  49  
  50  
  51  /*

  52  per http://oss.software.ibm.com/icu/apiref/classSimpleDateFormat.html

  53  

  54  

  55  

  56    Symbol   Meaning                 Presentation        Example

  57   ------   -------                 ------------        -------

  58   G        era designator          (Text)              AD

  59   y        year                    (Number)            1996

  60   Y        year (week of year)     (Number)            1997

  61   u        extended year           (Number)            4601

  62   M        month in year           (Text & Number)     July & 07

  63   d        day in month            (Number)            10

  64   h        hour in am/pm (1~12)    (Number)            12

  65   H        hour in day (0~23)      (Number)            0

  66   m        minute in hour          (Number)            30

  67   s        second in minute        (Number)            55

  68   S        fractional second       (Number)            978

  69   E        day of week             (Text)              Tuesday

  70   e        day of week (local 1~7) (Number)            2

  71   D        day in year             (Number)            189

  72   F        day of week in month    (Number)            2 (2nd Wed in July)

  73   w        week in year            (Number)            27

  74   W        week in month           (Number)            2

  75   a        am/pm marker            (Text)              PM

  76   k        hour in day (1~24)      (Number)            24

  77   K        hour in am/pm (0~11)    (Number)            0

  78   z        time zone               (Text)              Pacific Standard Time

  79   Z        time zone (RFC 822)     (Number)            -0800

  80   g        Julian day              (Number)            2451334

  81   A        milliseconds in day     (Number)            69540000

  82   '        escape for text         (Delimiter)         'Date='

  83   ''       single quote            (Literal)           'o''clock'

  84  

  85  

  86  

  87  

  88  The count of pattern letters determine the format.

  89  

  90  (Text): 4 or more, use full form, <4, use short or abbreviated form if it exists. (e.g., "EEEE" produces "Monday", "EEE" produces "Mon")

  91  

  92  (Number): the minimum number of digits. Shorter numbers are zero-padded to this amount (e.g. if "m" produces "6", "mm" produces "06"). Year is handled specially; that is, if the count of 'y' is 2, the Year will be truncated to 2 digits. (e.g., if "yyyy" produces "1997", "yy" produces "97".) Unlike other fields, fractional seconds are padded on the right with zero.

  93  

  94  (Text & Number): 3 or over, use text, otherwise use number. (e.g., "M" produces "1", "MM" produces "01", "MMM" produces "Jan", and "MMMM" produces "January".)

  95  

  96  Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

  97  

  98  A pattern containing any invalid pattern letter will result in a failing UErrorCode result during formatting or parsing.

  99  

 100  Examples using the US locale:

 101  

 102      Format Pattern                         Result

 103      --------------                         -------

 104      "yyyy.MM.dd G 'at' HH:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT

 105      "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96

 106      "h:mm a"                          ->>  12:08 PM

 107      "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time

 108      "K:mm a, z"                       ->>  0:00 PM, PST

 109      "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM

 110  

 111  

 112  */
 113  
 114  
 115  
 116  
 117  
 118  ?>


Generated: Thu Jan 8 04:06:23 2009 Cross-referenced by PHPXref 0.7