function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
// Slight hackish adjustment so that 'zero' datetime actually returns what is intended
- // otherwise we end up with -0001-11-30 ...
+ // otherwise we end up with -0001-11-30 ...
// add 32 days so that we at least get year 00, and then hack around the fact that
- // months and days always start with 1.
+ // months and days always start with 1.
if(substr($s,0,10) == '0000-00-00') {
$d = new DateTime($s . ' + 32 days', new DateTimeZone('UTC'));
$o .= "<option value=\"0000\" $sel ></option>";
}
- for($x = $ymax; $x >= $ymin; $x --) {
- $sel = (($x == $y) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"$x\" $sel>$x</option>";
+ if($ymax > $ymin) {
+ for($x = $ymax; $x >= $ymin; $x --) {
+ $sel = (($x == $y) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$x\" $sel>$x</option>";
+ }
+ }
+ else {
+ for($x = $ymax; $x <= $ymin; $x ++) {
+ $sel = (($x == $y) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$x\" $sel>$x</option>";
+ }
}
$o .= "</select> <select name=\"{$pre}month\" class=\"{$pre}month\" size=\"1\">";
- for($x = 0; $x <= 12; $x ++) {
+ for($x = (($allow_blank) ? 0 : 1); $x <= 12; $x ++) {
$sel = (($x == $m) ? " selected=\"selected\" " : "");
$y = (($x) ? $x : '');
$o .= "<option value=\"$x\" $sel>$y</option>";
}
$o .= "</select> <select name=\"{$pre}day\" class=\"{$pre}day\" size=\"1\">";
- for($x = 0; $x <= 31; $x ++) {
+ for($x = (($allow_blank) ? 0 : 1); $x <= 31; $x ++) {
$sel = (($x == $d) ? " selected=\"selected\" " : "");
$y = (($x) ? $x : '');
$o .= "<option value=\"$x\" $sel>$y</option>";
return $o;
}}
+if(! function_exists('timesel')) {
+function timesel($pre,$h,$m) {
+
+ $o = '';
+ $o .= "<select name=\"{$pre}hour\" class=\"{$pre}hour\" size=\"1\">";
+ for($x = 0; $x < 24; $x ++) {
+ $sel = (($x == $h) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$x\" $sel>$x</option>";
+ }
+ $o .= "</select> : <select name=\"{$pre}minute\" class=\"{$pre}minute\" size=\"1\">";
+ for($x = 0; $x < 60; $x ++) {
+ $sel = (($x == $m) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"$x\" $sel>$x</option>";
+ }
+
+ $o .= "</select>";
+ return $o;
+}}
+
+
+
+
+
+
+
+
// implements "3 seconds ago" etc.
// based on $posted_date, (UTC).
// Results relative to current timezone
$localtime = datetime_convert('UTC',date_default_timezone_get(),$posted_date);
$abs = strtotime($localtime);
+
+ if (is_null($posted_date) || $posted_date === '0000-00-00 00:00:00' || $abs === False) {
+ return t('never');
+ }
+
$etime = time() - $abs;
if ($etime < 1) {
}
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
- 30 * 24 * 60 * 60 => array( t('month'), t('months')),
- 7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
- 24 * 60 * 60 => array( t('day'), t('days')),
- 60 * 60 => array( t('hour'), t('hours')),
- 60 => array( t('minute'), t('minutes')),
- 1 => array( t('second'), t('seconds'))
+ 30 * 24 * 60 * 60 => array( t('month'), t('months')),
+ 7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
+ 24 * 60 * 60 => array( t('day'), t('days')),
+ 60 * 60 => array( t('hour'), t('hours')),
+ 60 => array( t('minute'), t('minutes')),
+ 1 => array( t('second'), t('seconds'))
);
foreach ($a as $secs => $str) {
if(! function_exists('cal')) {
-function cal($y = 0,$m = 0, $links = false) {
+function cal($y = 0,$m = 0, $links = false, $class='') {
// month table - start at 1 to match human usage.
$tddate = intval(datetime_convert('UTC',date_default_timezone_get(),'now','j'));
$str_month = day_translate($mtab[$m]);
- $o = '<table class="calendar">';
+ $o = '<table class="calendar' . $class . '">';
$o .= "<caption>$str_month $y</caption><tr>";
for($a = 0; $a < 7; $a ++)
- $o .= '<th>' . substr(day_translate($dn[$a]),0,3) . '</th>';
+ $o .= '<th>' . mb_substr(day_translate($dn[$a]),0,3,'UTF-8') . '</th>';
$o .= '</tr><tr>';
while($d <= $l) {