/** * validate parameter and execute the format. * * @param TstampTask reference to task */ public function execute(TstampTask $tstamp) { if (empty($this->propertyName)) { throw new BuildException("property attribute must be provided"); } if (empty($this->pattern)) { throw new BuildException("pattern attribute must be provided"); } if (!empty($this->locale)) { setlocale(LC_ALL, $this->locale); } $value = strftime($this->pattern); $tstamp->prefixProperty($this->propertyName, $value); if (!empty($this->locale)) { // reset locale setlocale(LC_ALL, NULL); } }
/** * validate parameter and execute the format. * * @param TstampTask $tstamp reference to task * @throws BuildException */ public function execute(TstampTask $tstamp) { if (empty($this->propertyName)) { throw new BuildException("property attribute must be provided"); } if (empty($this->pattern)) { throw new BuildException("pattern attribute must be provided"); } $oldlocale = ""; if (!empty($this->locale)) { $oldlocale = setlocale(LC_ALL, 0); setlocale(LC_ALL, $this->locale); } $savedTimezone = date_default_timezone_get(); if (!empty($this->timezone)) { date_default_timezone_set($this->timezone); } $value = strftime($this->pattern); $tstamp->prefixProperty($this->propertyName, $value); if (!empty($this->locale)) { // reset locale setlocale(LC_ALL, $oldlocale); } if (!empty($this->timezone)) { date_default_timezone_set($savedTimezone); } }