createOption('ShowCentiBeats', 'Show CentiBeats (more precision)?', 'yesno', 'yes'); } // --------- Various Functions ---------------------------- // code to calculate UTC offset based on // http://be2.php.net/manual/nl/function.localtime.php#27516 function getUTCOffset($timeOffset) { $Offset = date("O", time()); $Parity = $Offset < 0 ? -1 : 1; $Offset = $Parity * $Offset; $Offset = ($Offset - ($Offset % 100))/100*60 + $Offset % 100; return (($Parity * $Offset)/60)+$timeOffset; } function getBMTHour($iHour, $timeOffset) { //BMT is UTC+0100 (getUTCOffset+1) $tmp = $iHour-floor($this->getUTCOffset($timeOffset))+1; if ($tmp < 0) $tmp = 24+$tmp; if ($tmp == 24) $tmp = 0; return $tmp; } function getBMTMinutes($iMin, $timeOffset) { $offset = $this->getUTCOffset($timeOffset); $offset = $offset - floor($offset); return $iMin + round($offset*60); } function addLeadingZeroes($swatchTime) { if (strlen($swatchTime) == 2) $swatchTime = '0'.$swatchTime; elseif (strlen($swatchTime) == 1) $swatchBeat = '00'.$swatchTime; return $swatchTime; } function getInternetTime($iTime, $timeOffset) { $iTime_arr = localtime($iTime); $swatchBeat = (($this->getBMTHour($iTime_arr[2], $timeOffset)*60*60)+($this->getBMTMinutes($iTime_arr[1], $timeOffset)*60)+$iTime_arr[0])/86.4; if ($this->getOption('ShowCentiBeats') == 'yes') { $swatchBeat = round($swatchBeat, 2); $intPart = floor($swatchBeat); $fracPart = round(($swatchBeat - $intPart) * 100); $intPart = $this->addLeadingZeroes($intPart); if ($fracPart < 10) $fracPart = '0'.$fracPart; $swatchBeat = $intPart.'.'.$fracPart; } else { $swatchBeat = round($swatchBeat); $swatchBeat = $this->addLeadingZeroes($swatchBeat); } return $swatchBeat; } // --------- do...-Functions ------------------------------ function doSkinVar($skinType) { global $blog; echo '@'.$this->getInternetTime(time(), $blog->getTimeOffset); } function doTemplateVar(&$item) { global $blog; echo '@'.$this->getInternetTime($item->timestamp, $blog->getTimeOffset); } function doTemplateCommentsVar(&$item, &$comment) { global $blog; echo '@'.$this->getInternetTime($comment['timestamp'], $blog->getTimeOffset); } } ?>