mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
feature 2564: forgot a file in previous commit
git-svn-id: http://piwigo.org/svn/trunk@13085 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -492,7 +492,7 @@ INSERT INTO '.HISTORY_TABLE.'
|
||||
// The output is internationalized.
|
||||
//
|
||||
// format_date( "2003-09-15", true ) -> "Monday 15 September 2003 21:52"
|
||||
function format_date($date, $show_time = false)
|
||||
function format_date($date, $show_time = false, $show_day_name = true)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
@@ -516,7 +516,7 @@ function format_date($date, $show_time = false)
|
||||
|
||||
$formated_date = '';
|
||||
// before 1970, Microsoft Windows can't mktime
|
||||
if ($ymdhms[0] >= 1970)
|
||||
if ($show_day_name and $ymdhms[0] >= 1970)
|
||||
{
|
||||
// we ask midday because Windows think it's prior to midnight with a
|
||||
// zero and refuse to work
|
||||
@@ -532,6 +532,65 @@ function format_date($date, $show_time = false)
|
||||
return $formated_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Works out the time since the entry post, takes a an argument in unix time or datetime
|
||||
*/
|
||||
function time_since($original, $stop = 'minute')
|
||||
{
|
||||
if (!is_int($original))
|
||||
{
|
||||
$ymdhms = array();
|
||||
$tok = strtok($original, '- :');
|
||||
while ($tok !== false)
|
||||
{
|
||||
$ymdhms[] = $tok;
|
||||
$tok = strtok('- :');
|
||||
}
|
||||
$original = mktime($ymdhms[3],$ymdhms[4],$ymdhms[5],$ymdhms[1],$ymdhms[2],$ymdhms[0]);
|
||||
}
|
||||
|
||||
// array of time period chunks
|
||||
$chunks = array(
|
||||
array(60 * 60 * 24 * 365 , 'year'),
|
||||
array(60 * 60 * 24 * 30 , 'month'),
|
||||
array(60 * 60 * 24 * 7, 'week'),
|
||||
array(60 * 60 * 24 , 'day'),
|
||||
array(60 * 60 , 'hour'),
|
||||
array(60 , 'minute'),
|
||||
array(1 , 'second'),
|
||||
);
|
||||
|
||||
$today = time(); /* Current unix time */
|
||||
$since = abs($today - $original);
|
||||
|
||||
$print = null;
|
||||
for ($i = 0, $j = count($chunks); $i < $j; $i++)
|
||||
{
|
||||
$seconds = $chunks[$i][0];
|
||||
$name = $chunks[$i][1];
|
||||
if (($count = floor($since / $seconds)) != 0)
|
||||
{
|
||||
$print.= ($count == 1) ? '1 '.l10n($name).' ' : $count.' '.l10n($name.'s').' ';
|
||||
$since-= $count*$seconds;
|
||||
}
|
||||
if ($name == $stop)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($today > $original)
|
||||
{
|
||||
$print = sprintf(l10n('%s ago'), $print);
|
||||
}
|
||||
else
|
||||
{
|
||||
$print = sprintf(l10n('%s in the future'), $print);
|
||||
}
|
||||
|
||||
return $print;
|
||||
}
|
||||
|
||||
function pwg_debug( $string )
|
||||
{
|
||||
global $debug,$t2,$page;
|
||||
|
||||
Reference in New Issue
Block a user