/**
  * Time can be generated from string by using the factory method
  */
 public function testFactoryMethod()
 {
     // test with default timezone
     $time = qCal_Time::factory("1:30pm");
     // should default to America/Los_Angeles
     $this->assertEqual($time->getHour(), 13);
     $this->assertEqual($time->getMinute(), 30);
     $this->assertEqual($time->getSecond(), 0);
     $this->assertEqual($time->getTimezone()->getName(), date_default_timezone_get());
     // test with specific timezone
     $time = qCal_Time::factory("1:30pm", "MST");
     // GMT - 7 hours
     $this->assertEqual($time->getHour(), 13);
     // timezone doesn't change the time
     $this->assertEqual($time->getMinute(), 30);
     $this->assertEqual($time->getSecond(), 0);
     $this->assertEqual($time->getTimezone()->getName(), "MST");
 }
 /**
  * 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");
 }
 /**
  * This converts to a qCal_Date for internal storage
  */
 protected function doCast($value)
 {
     $date = qCal_Time::factory($value);
     return $date;
 }
 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"
 }