123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <?php
- /**
- * Skeleton subclass for representing a row from the 'cc_schedule' table.
- *
- *
- *
- * You should add additional methods to this class to meet the
- * application requirements. This class will only be generated as
- * long as it does not already exist in the output directory.
- *
- * @package propel.generator.airtime
- */
- class CcSchedule extends BaseCcSchedule {
- /**
- * Get the [optionally formatted] temporal [starts] column value.
- *
- *
- * @param string $format The date/time format string (either date()-style or strftime()-style).
- * If format is NULL, then the raw DateTime object will be returned.
- * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
- * @throws PropelException - if unable to parse/validate the date/time value.
- */
- public function getDbStarts($format = 'Y-m-d H:i:s.u')
- {
- if ($this->starts === null) {
- return null;
- }
- try {
- $dt = new DateTime($this->starts, new DateTimeZone("UTC"));
- } catch (Exception $x) {
- throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->starts, true), $x);
- }
- if ($format === null) {
- // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
- return $dt;
- } elseif (strpos($format, '%') !== false) {
- return strftime($format, $dt->format('U'));
- } else {
- return $dt->format($format);
- }
- }
- /**
- * Get the [optionally formatted] temporal [ends] column value.
- *
- *
- * @param string $format The date/time format string (either date()-style or strftime()-style).
- * If format is NULL, then the raw DateTime object will be returned.
- * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
- * @throws PropelException - if unable to parse/validate the date/time value.
- */
- public function getDbEnds($format = 'Y-m-d H:i:s.u')
- {
- if ($this->ends === null) {
- return null;
- }
- try {
- $dt = new DateTime($this->ends, new DateTimeZone("UTC"));
- } catch (Exception $x) {
- throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->ends, true), $x);
- }
- if ($format === null) {
- // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
- return $dt;
- } elseif (strpos($format, '%') !== false) {
- return strftime($format, $dt->format('U'));
- } else {
- return $dt->format($format);
- }
- }
- /**
- * Get the [optionally formatted] temporal [fadein] column value.
- *
- * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
- * @throws PropelException - if unable to parse/validate the date/time value.
- */
- public function getDbFadeIn($format = "s.u")
- {
- return parent::getDbFadein($format);
- }
- /**
- * Get the [optionally formatted] temporal [fadein] column value.
- *
- * @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
- * @throws PropelException - if unable to parse/validate the date/time value.
- */
- public function getDbFadeOut($format = "s.u")
- {
- return parent::getDbFadeout($format);
- }
- /**
- *
- * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
- *
- * @return CcPlaylistcontents The current object (for fluent API support)
- */
- public function setDbFadeIn($v)
- {
- $microsecond = 0;
- if ($v instanceof DateTime) {
- $dt = $v;
- }
- else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
- // in php 5.3.2 createFromFormat() with "u" is not supported(bug)
- // Hence we need to do parsing.
- $info = explode('.', $v);
- $microsecond = $info[1];
- $dt = DateTime::createFromFormat("s", $info[0]);
- }
- else {
- try {
- $dt = new DateTime($v);
- } catch (Exception $x) {
- throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
- }
- }
- if ($microsecond == 0) {
- $this->fade_in = $dt->format('H:i:s.u');
- } else {
- $this->fade_in = $dt->format('H:i:s').".".$microsecond;
- }
- $this->modifiedColumns[] = CcSchedulePeer::FADE_IN;
- return $this;
- } // setDbFadein()
- /**
- *
- * @param String in format SS.uuuuuu, Datetime, or DateTime accepted string.
- *
- * @return CcPlaylistcontents The current object (for fluent API support)
- */
- public function setDbFadeOut($v)
- {
- $microsecond = 0;
- if ($v instanceof DateTime) {
- $dt = $v;
- }
- else if (preg_match('/^[0-9]{1,2}(\.\d{1,6})?$/', $v)) {
- // in php 5.3.2 createFromFormat() with "u" is not supported(bug)
- // Hence we need to do parsing.
- $info = explode('.', $v);
- $microsecond = $info[1];
- $dt = DateTime::createFromFormat("s", $info[0]);
- }
- else {
- try {
- $dt = new DateTime($v);
- } catch (Exception $x) {
- throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
- }
- }
- if ($microsecond == 0) {
- $this->fade_out = $dt->format('H:i:s.u');
- } else {
- $this->fade_out = $dt->format('H:i:s').".".$microsecond;
- }
- $this->modifiedColumns[] = CcSchedulePeer::FADE_OUT;
- return $this;
- } // setDbFadeout()
- /**
- * Sets the value of [starts] column to a normalized version of the date/time value specified.
- *
- * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
- * be treated as NULL for temporal objects.
- * @return CcSchedule The current object (for fluent API support)
- */
- public function setDbStarts($v)
- {
- $utcTimeZone = new DateTimeZone('UTC');
-
- if ($v instanceof DateTime) {
- $dt = $v;
- $dt->setTimezone($utcTimeZone);
- } else {
- // some string/numeric value passed; we normalize that so that we can
- // validate it.
- try {
- if (is_numeric($v)) { // if it's a unix timestamp
- $dt = new DateTime('@'.$v, $utcTimeZone);
-
- } else {
- $dt = new DateTime($v, $utcTimeZone);
- }
- } catch (Exception $x) {
- throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
- }
- }
- $this->starts = ($dt ? $dt->format('Y-m-d H:i:s.u') : null);
- $this->modifiedColumns[] = CcSchedulePeer::STARTS;
- return $this;
- } // setDbStarts()
- /**
- * Sets the value of [ends] column to a normalized version of the date/time value specified.
- *
- * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
- * be treated as NULL for temporal objects.
- * @return CcSchedule The current object (for fluent API support)
- */
- public function setDbEnds($v)
- {
- $utcTimeZone = new DateTimeZone('UTC');
-
- if ($v instanceof DateTime) {
- $dt = $v;
- $dt->setTimezone($utcTimeZone);
- } else {
- // some string/numeric value passed; we normalize that so that we can
- // validate it.
- try {
- if (is_numeric($v)) { // if it's a unix timestamp
- $dt = new DateTime('@'.$v, $utcTimeZone);
-
- } else {
- $dt = new DateTime($v, $utcTimeZone);
- }
- } catch (Exception $x) {
- throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
- }
- }
- $this->ends = ($dt ? $dt->format('Y-m-d H:i:s.u') : null);
- $this->modifiedColumns[] = CcSchedulePeer::ENDS;
- return $this;
- } // setDbEnds()
-
- public function isCurrentItem($epochNow = null) {
-
- if (is_null($epochNow)) {
- $epochNow = microtime(true);
- }
-
- $epochStart = floatval($this->getDbStarts('U.u'));
- $epochEnd = floatval($this->getDbEnds('U.u'));
-
- if ($epochStart < $epochNow && $epochEnd > $epochNow) {
- return true;
- }
-
- return false;
- }
- } // CcSchedule
|