예제 #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     if ($this->sampleList === null) {
         $d1 = new Date(2012, 5, 21);
         $d2 = new Datetime(2012, 5, 21, 7, 30);
         $d3 = new Timestamp(2012, 5, 21, 7, 30, 9);
         $d4 = new Date(2012, 3, 7);
         $d5 = new Datetime(2012, 3, 7, 0, 0);
         $d6 = new Timestamp(2012, 3, 7, 0, 0, 0);
         $d7 = Date::now();
         $d8 = Datetime::now()->setAll(array("hour" => 8, "minute" => 6));
         $d9 = Timestamp::now()->setAll(array("hour" => 8, "minute" => 6, "second" => 4));
         $this->sampleList = array(new SimpleFormatTest_Sample("YmdHis", new SimpleFormatTest_ParseData("20120521073009", "2012052112345", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "20120521000000"), new SimpleFormatTest_FormatData($d2, "20120521073000"), new SimpleFormatTest_FormatData($d3, "20120521073009")), new SimpleFormatTest_Sample("Y年n月j日G時f分b秒", new SimpleFormatTest_ParseData("2012年5月21日7時30分9秒", "2012年05月21日07時30分09秒", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "2012年5月21日0時0分0秒"), new SimpleFormatTest_FormatData($d2, "2012年5月21日7時30分0秒"), new SimpleFormatTest_FormatData($d3, "2012年5月21日7時30分9秒")), new SimpleFormatTest_Sample("\\Y=Y \\n=n \\j=j \\H=H \\i=i \\s=s", new SimpleFormatTest_ParseData("Y=2012 n=5 j=21 H=07 i=30 s=09", "Y=2012 n=5 j=21 H=7 i=30 s=9", $d1, $d2, $d3), new SimpleFormatTest_FormatData($d1, "Y=2012 n=5 j=21 H=00 i=00 s=00"), new SimpleFormatTest_FormatData($d2, "Y=2012 n=5 j=21 H=07 i=30 s=00"), new SimpleFormatTest_FormatData($d3, "Y=2012 n=5 j=21 H=07 i=30 s=09")), new SimpleFormatTest_Sample("Y/m/d", new SimpleFormatTest_ParseData("2012/03/07", "2012-03-07", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012/05/21"), new SimpleFormatTest_FormatData($d2, "2012/05/21"), new SimpleFormatTest_FormatData($d3, "2012/05/21")), new SimpleFormatTest_Sample("Y.n.j", new SimpleFormatTest_ParseData("2012.3.7", "hogehoge", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012.5.21"), new SimpleFormatTest_FormatData($d2, "2012.5.21"), new SimpleFormatTest_FormatData($d3, "2012.5.21")), new SimpleFormatTest_Sample("H:i:s", new SimpleFormatTest_ParseData("08:06:04", "8:06:04", $d7, $d8, $d9), new SimpleFormatTest_FormatData($d1, "00:00:00"), new SimpleFormatTest_FormatData($d2, "07:30:00"), new SimpleFormatTest_FormatData($d3, "07:30:09")), new SimpleFormatTest_Sample("G時f分b秒", new SimpleFormatTest_ParseData("8時6分4秒", "8じ6分4秒", $d7, $d8, $d9), new SimpleFormatTest_FormatData($d1, "0時0分0秒"), new SimpleFormatTest_FormatData($d2, "7時30分0秒"), new SimpleFormatTest_FormatData($d3, "7時30分9秒")), new SimpleFormatTest_Sample("Y年n月j日(E)", new SimpleFormatTest_ParseData("2012年3月7日(水)", "2012年3月7日(無)", $d4, $d5, $d6), new SimpleFormatTest_FormatData($d1, "2012年5月21日(月)"), new SimpleFormatTest_FormatData($d2, "2012年5月21日(月)"), new SimpleFormatTest_FormatData($d3, "2012年5月21日(月)")));
     }
 }
예제 #2
0
 /**
  * Gets the number of days between current Date objcet and the specified Date.
  *
  * If Date is not specified, current Date is taken (see Date::now()).
  *
  * Result can be negative if current Date object > the specified Date.
  *
  * @return int
  */
 function getPassedDays(Date $to = null)
 {
     return self::dayDifference($this, $to ? $to : Timestamp::now());
 }