46 return setlocale(LC_ALL, self::getLocale());
86 return 'Europe/London';
111 'xx-small' =>
'xx-Small',
112 'x-small' =>
'x-Small',
114 'medium' =>
'Medium',
116 'x-large' =>
'x-Large',
117 'xx-large' =>
'xx-Large'
126 return array(
'http://www.xoops.org/backend.php');
135 return "\T\o\d\a\y G:i";
143 return "\Y\\e\s\\t\\e\\r\d\a\y G:i";
167 return "Y/n/j G:i:s";
194 public static function substr($str,
$start, $length, $trimmarker =
'...')
196 if (!self::isMultiByte()) {
197 return (strlen($str) -
$start <= $length)
199 :
substr($str,
$start, $length - strlen($trimmarker)) . $trimmarker;
201 if (function_exists(
'mb_internal_encoding') && @mb_internal_encoding(self::getCharset())) {
202 $str2 = mb_strcut($str,
$start, $length - strlen($trimmarker));
204 return $str2 . (mb_strlen($str) != mb_strlen($str2) ? $trimmarker :
'');
219 if (self::isMultiByte()) {
220 if (function_exists(
'mb_convert_encoding')) {
221 return mb_convert_encoding(
$text,
'UTF-8',
'auto');
238 $xlanguage =
$xoops->registry()->get(
'XLANGUAGE', array());
240 if (isset($xlanguage[
'charset_base'])) {
241 $charset = $xlanguage[
'charset_base'];
249 if (empty($to) || !strcasecmp($to, $from)) {
253 if (self::isMultiByte() && function_exists(
'mb_convert_encoding')) {
254 $converted_text = @mb_convert_encoding(
$text, $to, $from);
255 } elseif (function_exists(
'iconv')) {
256 $converted_text = @iconv($from, $to .
"//TRANSLIT",
$text);
257 } elseif (
'utf-8' == $to) {
260 $text = empty($converted_text) ?
$text : $converted_text;
292 $format_copy = $format;
293 $format = strtolower($format);
295 if ($format ==
'rss' || $format ==
'r') {
297 if (
$xoops->getConfig(
'server_TZ')) {
298 $server_TZ = abs(intval(
$xoops->getConfig(
'server_TZ') * 3600.0));
299 $prefix = (
$xoops->getConfig(
'server_TZ') < 0) ?
' -' :
' +';
300 $TIME_ZONE = $prefix . date(
'Hi', $server_TZ);
302 $date = gmdate(
'D, d M Y H:i:s', intval($time)) . $TIME_ZONE;
307 if (($format ==
'elapse' || $format ==
'e') && $time < time()) {
308 $elapse = time() - $time;
309 if ($days = floor($elapse / (24 * 3600))) {
311 } elseif ($hours = floor(($elapse % (24 * 3600)) / 3600)) {
313 } elseif ($minutes = floor(($elapse % 3600) / 60)) {
316 $seconds = $elapse % 60;
324 if ($timeoffset === null) {
325 $timeoffset = (
$xoops->getConfig(
'default_TZ') ==
'') ?
'0.0' :
$xoops->getConfig(
'default_TZ');
327 $usertimestamp =
$xoops->getUserTimestamp($time, $timeoffset);
330 $datestring = self::getFormatShortDate();
334 $datestring = self::getFormatMediumDate();
338 $datestring =
'Y-m-d H:i:s';
342 $datestring = self::getFormatLongDate();
347 static $current_timestamp, $today_timestamp, $monthy_timestamp;
348 if (!isset($current_timestamp)) {
349 $current_timestamp =
$xoops->getUserTimestamp(time(), $timeoffset);
351 if (!isset($today_timestamp)) {
352 $today_timestamp = mktime(0, 0, 0, gmdate(
'm', $current_timestamp), gmdate(
'd', $current_timestamp), gmdate(
'Y', $current_timestamp));
355 if (abs($elapse_today = $usertimestamp - $today_timestamp) < 24 * 60 * 60) {
358 if (!isset($monthy_timestamp)) {
359 $monthy_timestamp[0] = mktime(0, 0, 0, 0, 0, gmdate(
'Y', $current_timestamp));
360 $monthy_timestamp[1] = mktime(0, 0, 0, 0, 0, gmdate(
'Y', $current_timestamp) + 1);
362 if ($usertimestamp >= $monthy_timestamp[0] && $usertimestamp < $monthy_timestamp[1]) {
363 $datestring = self::getFormatMonthDay();
365 $datestring = self::getFormatYearMonthDay();
372 $datestring = $format_copy;
374 $datestring = self::getFormatLongDate();
379 return ucfirst(gmdate($datestring, $usertimestamp));
400 if (function_exists(
'money_format')) {
403 $result = sprintf(
'%01.2f', $number);
static utf8_encode($text)
static getLegacyLanguage()
static formatTimestamp($time, $format= 'l', $timeoffset=null)
static getFormatYearMonthDay()
static getFormatYesterday()
static convert_encoding($text, $to= 'utf-8', $from= '')
static getFormatMediumDate()
static getFormatShortDate()
static number_format($number)
static getFormatLongDate()
static getFormatMonthDay()
static substr($str, $start, $length, $trimmarker= '...')
static money_format($format, $number)