Index: Swat/SwatDate.php =================================================================== --- Swat/SwatDate.php (revision 10193) +++ Swat/SwatDate.php (working copy) @@ -11,9 +11,42 @@ */ class SwatDate extends Date { - // {{{ constants + // {{{ time zone format constants /** + * America/Halifax + */ + const TZ_ID = 1; + + /** + * AST + */ + const TZ_SHORT = 2; + + /** + * Atlantic Standard Time + */ + const TZ_LONG = 3; + + /** + * ADT + */ + const TZ_DST_SHORT = 4; + + /** + * Atlantic Daylight Time + */ + const TZ_DST_LONG = 5; + + /** + * AST/ADT + */ + const TZ_COMBINED_SHORT = 6; + + // }}} + // {{{ date format constants + + /** * 07/02/02 */ const DF_MDY = 1; @@ -96,12 +129,39 @@ * * @return string the formatted date. */ - public function format($format) + public function format($format, $tz_format = null) { if (is_int($format)) $format = self::getFormatById($format); - return parent::format($format); + $out = parent::format($format); + + if ($tz_format !== null) { + $out.= ' '; + + switch ($tz_format) { + case self::TZ_ID: + $out.= $this->tz->id; + break; + case self::TZ_SHORT: + $out.= $this->tz->shortname; + break; + case self::TZ_LONG: + $out.= $this->tz->longname; + break; + case self::TZ_DST_SHORT: + $out.= $this->tz->dstshortname; + break; + case self::TZ_DST_LONG: + $out.= $this->tz->dstlongname; + break; + case self::TZ_COMBINED_SHORT: + $out.= sprintf('%s/%s', $this->tz->shortname, $this->tz->dstshortname); + break; + } + } + + return $out; } // }}} @@ -118,7 +178,7 @@ } // }}} - // {{{ public static function getFormatById( + // {{{ public static function getFormatById() /** * Gets a date format string by id Index: Swat/SwatDateCellRenderer.php =================================================================== --- Swat/SwatDateCellRenderer.php (revision 10193) +++ Swat/SwatDateCellRenderer.php (working copy) @@ -36,6 +36,15 @@ public $format = SwatDate::DF_DATE_TIME; /** + * Time Zone Format + * + * A time zone format class constant from SwatDate. + * + * @var integer + */ + public $time_zone_format = null; + + /** * The time zone to render the date in * * The time zone may be specified either as a time zone identifier valid @@ -70,7 +79,7 @@ $date->convertTZbyID($this->display_time_zone); } - echo SwatString::minimizeEntities($date->format($this->format)); + echo SwatString::minimizeEntities($date->format($this->format, $this->time_zone_format)); } }