CcShowDays.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Skeleton subclass for representing a row from the 'cc_show_days' table.
  4. *
  5. *
  6. *
  7. * You should add additional methods to this class to meet the
  8. * application requirements. This class will only be generated as
  9. * long as it does not already exist in the output directory.
  10. *
  11. * @package propel.generator.airtime
  12. */
  13. class CcShowDays extends BaseCcShowDays {
  14. public function isRepeating()
  15. {
  16. return $this->getDbRepeatType() != -1;
  17. }
  18. public function getUTCStartDateAndTime()
  19. {
  20. $dt = new DateTime(
  21. "{$this->getDbFirstShow()} {$this->getDbStartTime()}",
  22. new DateTimeZone($this->getDbTimezone())
  23. );
  24. $dt->setTimezone(new DateTimeZone("UTC"));
  25. return $dt;
  26. }
  27. // Returns the start of a show in the timezone it was created in
  28. public function getLocalStartDateAndTime()
  29. {
  30. $dt = new DateTime(
  31. "{$this->getDbFirstShow()} {$this->getDbStartTime()}",
  32. new DateTimeZone($this->getDbTimezone())
  33. );
  34. //set timezone to that of the show
  35. //$dt->setTimezone(new DateTimeZone($this->getDbTimezone()));
  36. return $dt;
  37. }
  38. /**
  39. *
  40. * Returns the end of a show in the timezone it was created in
  41. * @param DateTime $startDateTime first show in show's local time
  42. */
  43. public function getLocalEndDateAndTime()
  44. {
  45. $startDateTime = $this->getLocalStartDateAndTime();
  46. $duration = explode(":", $this->getDbDuration());
  47. return $startDateTime->add(new DateInterval('PT'.$duration[0].'H'.$duration[1].'M'));
  48. }
  49. public function isShowStartInPast()
  50. {
  51. return $this->getUTCStartDateAndTime()->format("Y-m-d H:i:s") < gmdate("Y-m-d H:i:s");
  52. }
  53. public function formatDuration()
  54. {
  55. $info = explode(':',$this->getDbDuration());
  56. return str_pad(intval($info[0]),2,'0',STR_PAD_LEFT).'h '.str_pad(intval($info[1]),2,'0',STR_PAD_LEFT).'m';
  57. }
  58. } // CcShowDays