mirror of
https://github.com/e107inc/e107.git
synced 2025-08-07 23:26:41 +02:00
better date converting
This commit is contained in:
@@ -11,9 +11,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $
|
||||||
| $Revision: 1.6 $
|
| $Revision: 1.7 $
|
||||||
| $Date: 2009-08-15 11:55:30 $
|
| $Date: 2009-10-22 19:14:26 $
|
||||||
| $Author: marj_nl_fr $
|
| $Author: secretr $
|
||||||
|
|
|
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -23,26 +23,43 @@ include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_date.php");
|
|||||||
|
|
||||||
class convert
|
class convert
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
function convert_date($datestamp, $mode = "long") {
|
* Convert datestamp to human readable date.
|
||||||
/*
|
* System time offset is considered.
|
||||||
# Date convert
|
*
|
||||||
# - parameter #1: string $datestamp, unix stamp
|
* @param integer $datestamp unix stamp
|
||||||
# - parameter #2: string $mode, date format, default long
|
* @param string $mask [optional] long|short|forum or any strftime() valid string
|
||||||
# - return parsed text
|
*
|
||||||
# - scope public
|
* @return string parsed date
|
||||||
*/
|
*/
|
||||||
global $pref;
|
function convert_date($datestamp, $mask = '') {
|
||||||
|
if(empty($mask))
|
||||||
|
{
|
||||||
|
$mask = 'long';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($mask)
|
||||||
|
{
|
||||||
|
case 'long':
|
||||||
|
$mask = e107::getPref('longdate');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'short':
|
||||||
|
$mask = e107::getPref('shortdate');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'forum': // DEPRECATED - temporary here from BC reasons only
|
||||||
|
default:
|
||||||
|
//BC - old 'forum' call
|
||||||
|
if(strpos('%', $mask) === FALSE)
|
||||||
|
{
|
||||||
|
$mask = e107::getPref('forumdate');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$datestamp += TIMEOFFSET;
|
$datestamp += TIMEOFFSET;
|
||||||
|
return strftime($mask, $datestamp);
|
||||||
if ($mode == "long") {
|
|
||||||
return strftime($pref['longdate'], $datestamp);
|
|
||||||
} else if ($mode == "short") {
|
|
||||||
return strftime($pref['shortdate'], $datestamp);
|
|
||||||
} else {
|
|
||||||
return strftime($pref['forumdate'], $datestamp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long')
|
function computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long')
|
||||||
|
Reference in New Issue
Block a user