1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-09 08:06:38 +02:00

new module creation

This commit is contained in:
mcfly
2006-12-02 04:36:16 +00:00
commit e149b35fcc
2196 changed files with 182987 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:33:42 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
if (is_readable(e_LANGUAGEDIR.e_LANGUAGE."/lan_date.php")) {
@include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_date.php");
} else {
@include_once(e_LANGUAGEDIR."English/lan_date.php");
}
class convert
{
function convert_date($datestamp, $mode = "long") {
/*
# Date convert
# - parameter #1: string $datestamp, unix stamp
# - parameter #2: string $mode, date format, default long
# - return parsed text
# - scope public
*/
global $pref;
$datestamp += TIMEOFFSET;
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')
{
/*
$mode = TRUE :: return array
$mode = FALSE :: return string
*/
$newer_date = ($newer_date == FALSE ? (time()) : $newer_date);
$since = $newer_date - $older_date;
if($format == 'short')
{
$sec = LANDT_09;
$secs = LANDT_09s;
$min = LANDT_08;
$mins = LANDT_08s;
}
else
{
$sec = LANDT_07;
$secs = LANDT_07s;
$min = LANDT_06;
$mins = LANDT_06s;
}
$timings = array(
array(31536000 , LANDT_01,LANDT_01s),
array(2592000 , LANDT_02, LANDT_02s),
array(604800, LANDT_03, LANDT_03s),
array(86400 , LANDT_04, LANDT_04s),
array(3600 , LANDT_05, LANDT_05s),
array(60 , $min, $mins)
);
if($show_secs)
{
$timings[] = array(1 , $sec, $secs);
}
$newer_date = ($newer_date == FALSE ? (time()) : $newer_date);
$since = $newer_date - $older_date;
$outputArray = array();
$total = $since;
$value = FALSE;
foreach($timings as $time)
{
$seconds = floor($total / $time[0]);
if($seconds || $value)
{
$outputArray[] = $seconds." ".($seconds == 1 ? $time[1] : $time[2]);
$value = TRUE;
}
$total = fmod($total, $time[0]);
}
return ($mode ? $outputArray : implode(", ", $outputArray));
}
}