示例#1
0
文件: Date.php 项目: tourze/base
 /**
  * 返回一年中的12个月份
  *
  *     Date::months();
  *     // array(1 => 1, 2 => 2, 3 => 3, ..., 12 => 12)
  *
  * 可以使用Date::MONTHS_LONG来使其返回带月份的格式
  *
  *     Date::months(Date::MONTHS_LONG);
  *     // array(1 => 'January', 2 => 'February', ..., 12 => 'December')
  *
  * Date::MONTHS_SHORT返回月份的短格式
  *
  *     Date::months(Date::MONTHS_SHORT);
  *     // array(1 => 'Jan', 2 => 'Feb', ..., 12 => 'Dec')
  *
  * @param  string $format 月份格式
  * @return array
  */
 public static function months($format = null)
 {
     $months = [];
     if ($format === Date::MONTHS_LONG || $format === Date::MONTHS_SHORT) {
         for ($i = 1; $i <= 12; ++$i) {
             $months[$i] = strftime($format, mktime(0, 0, 0, $i, 1));
         }
     } else {
         $array = Arr::range(1, 12);
         foreach ($array as $i) {
             $months[$i] = $i;
         }
     }
     return $months;
 }
示例#2
0
文件: ArrTest.php 项目: tourze/base
 /**
  * 校验[Arr::range]方法
  *
  * @dataProvider dataRange
  * @param mixed $step
  * @param mixed $max
  * @param mixed $expect
  */
 public function testRange($step, $max, $expect)
 {
     $this->assertEquals($expect, Arr::range($step, $max));
 }