コード例 #1
0
 /**
  * All of PHP's date function's time-related meta-characters should work with this class
  * Any of the other meta-characters defined for date() do not work.
  */
 public function testFormatDateMetacharacters()
 {
     $time = new qCal_Time(4, 20, 0, "GMT");
     $this->assertEqual($time->__toString(), "04:20:00");
     $this->assertEqual($time->format("g:ia"), "4:20am");
 }
 public function testTimeToString()
 {
     $time = new qCal_Time(4, 0, 0);
     $this->assertEqual($time->__toString(), "04:00:00");
     // will output "04:00:00"
     $time = new qCal_Time(15, 30, 30);
     $time->setFormat("g:ia");
     $this->assertEqual($time->__toString(), "3:30pm");
     // outputs "3:30pm"
     $time->setFormat("H");
     $this->assertEqual($time->__toString(), "15");
     // outputs "15"
     $time = new qCal_Time(6, 30, 0);
     $string = $time->format("H:i");
     $this->assertEqual($time->__toString(), "06:30:00");
     // still outputs "06:30:00" because we did not call setFormat()
     $this->assertEqual($string, "06:30");
     // outputs "06:30"
 }