/** * render * * @return string rendered form element */ public function render() { $xoops = \Xoops::getInstance(); $display_value = \Xoops\Core\Locale\Time::formatDate($this->getValue(false)); $dataList = $this->isDatalist(); if (!empty($dataList)) { $this->add('list', 'list_' . $this->getName()); } $this->themeDecorateElement(); $this->suppressRender(['value']); $attributes = $this->renderAttributeString(); $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss'); $xoops->theme()->addBaseScriptAssets('@jqueryui'); \Xoops\Core\Locale\Time::localizeDatePicker(); $xoops->theme()->addScript('', '', ' $(function() { $( "#' . $this->get('id') . '" ).datepicker({' . 'showOn: "button", buttonImageOnly: false, changeYear: true, constrainInput: false, ' . 'buttonImage: "' . $xoops->url('media/xoops/images/icons/calendar.png') . '", ' . 'buttonImageOnly: false, buttonText: "' . \XoopsLocale::A_SELECT . '" }); }); '); return '<input ' . $attributes . 'value="' . $display_value . '" ' . $this->getExtra() . ' >'; }
/** * Function to display formatted times in user timezone * * @param mixed $time * @param string $format Format codes () * 's' or 'short' - short; * 'm' or 'medium' - medium; * 'l' or 'long' - long; * 'c' or 'custom' - format determined according to interval to present; * 'e' or 'elapse' - Elapsed; * 'mysql' - Y-m-d H:i:s; * 'rss' * * @return string */ public static function formatTimestamp($time, $format = 'l') { $workingTime = Time::cleanTime($time); switch (strtolower($format)) { case 'short': case 's': return Time::formatDateTime($workingTime, 'short'); case 'medium': case 'm': return Time::formatDateTime($workingTime, 'medium'); case 'long': case 'l': return Time::formatDateTime($workingTime, 'long'); case 'full': case 'f': return Time::formatDateTime($workingTime, 'full'); case 'custom': case 'c': $specialName = Calendar::getDateRelativeName($workingTime, true); if ($specialName != '') { return $specialName; } // no break - fall through // no break - fall through case 'elapse': case 'e': return Time::describeRelativeInterval($workingTime); case 'short-date': return Time::formatDate($workingTime, 'short'); case 'short-time': return Time::formatTime($workingTime, 'short'); case 'medium-date': return Time::formatDate($workingTime, 'medium'); case 'medium-time': return Time::formatTime($workingTime, 'medium'); case 'long-date': return Time::formatDate($workingTime, 'long'); case 'long-time': return Time::formatTime($workingTime, 'long'); case 'full-date': return Time::formatDate($workingTime, 'full'); case 'full-time': return Time::formatTime($workingTime, 'full'); case 'rss': $workingTime->setTimezone(new \DateTimeZone('UTC')); return $workingTime->format($workingTime::RSS); case 'mysql': $workingTime->setTimezone(new \DateTimeZone('UTC')); return $workingTime->format('Y-m-d H:i:s'); default: if ($format != '') { return $workingTime->format($format); } return Time::formatDateTime($workingTime, 'long'); break; } }