/** * Now test that registering the timezone prevents the exception */ public function testCustomTimezoneRegister() { // now we register the timezone so that we can use it $timezone = new qCal_Timezone("Custom", "5400", "CSTM", false); qCal_Timezone::register($timezone); // Create a new time with the custom timezone. The time should now be 12:00:00 in the custom timezone... $time = new qCal_Time(0, 0, 0, "Custom"); $this->assertEqual($time->getTimezone(), $timezone); $this->assertEqual($time->getTimezone()->getOffsetSeconds(), "5400"); // $this->assertEqual($time->getTimestamp(), "5400"); $this->assertEqual($time->__toString(), "00:00:00"); }
/** * Test that metacharacters can be escaped with a backslash */ public function testEscapeMetacharacters() { $time = new qCal_Time(0, 0, 0, "GMT"); $time->setFormat("\\G:\\i:\\s\\a G:i:sa"); $this->assertEqual($time->__toString(), "G:i:sa 0:00:00am"); }
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" }