mirror of
https://github.com/e107inc/e107.git
synced 2025-07-23 07:52:07 +02:00
strftime() added to php_compatibility_handler.php and all references updated. README updated. dateAlternativeTest updated to pass on Windows. (TBD)
This commit is contained in:
@@ -36,8 +36,9 @@
|
||||
|
||||
### Recommended
|
||||
|
||||
* Apache 2.2 or newer on Linux with PHP 7.0 or newer
|
||||
* MySQL 5.x or newer, or MariaDB
|
||||
* Apache 2.4 or newer on Linux
|
||||
* PHP 7.4 or newer
|
||||
* MySQL 5.6 or newer, or MariaDB 10.3 or newer
|
||||
* A registered domain name
|
||||
* Access to a server control panel (such as cPanel)
|
||||
|
||||
|
@@ -371,7 +371,7 @@ class admin_log_ui extends e_admin_ui
|
||||
if(($action == "backdel") && isset($_POST['backdeltype']))
|
||||
{
|
||||
// $old_date = intval($qs[1]);
|
||||
$old_string = e_date::strftime("%d %B %Y", $old_date);
|
||||
$old_string = strftime("%d %B %Y", $old_date);
|
||||
$qry = "dblog_datestamp < ".$old_date; // Same field for both logs
|
||||
|
||||
switch($_POST['backdeltype'])
|
||||
|
@@ -65,7 +65,7 @@ if (!empty($_POST['ban_types']))
|
||||
}
|
||||
}
|
||||
|
||||
$filename = 'banlist_'.e_date::strftime("%Y%m%d_%H%M%S").'.csv';
|
||||
$filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv';
|
||||
|
||||
if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote))
|
||||
{
|
||||
@@ -98,7 +98,7 @@ function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $
|
||||
break;
|
||||
case 'banlist_datestamp' :
|
||||
case 'banlist_banexpires' :
|
||||
if ($row[$f]) $line .= $spacer.$quot.e_date::strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot;
|
||||
if ($row[$f]) $line .= $spacer.$quot.strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot;
|
||||
break;
|
||||
}
|
||||
$spacer = $sep;
|
||||
|
@@ -542,9 +542,9 @@ class cron_admin_form_ui extends e_admin_form_ui
|
||||
$text .= "<br />";
|
||||
$text .= ($day != '*') ? LAN_CRON_52 ." ". $day : LAN_CRON_40; // Day(s)
|
||||
$text .= "<br />";
|
||||
$text .= ($month != '*') ? LAN_CRON_53 ." ". e_date::strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s)
|
||||
$text .= ($month != '*') ? LAN_CRON_53 ." ". strftime("%B", mktime(00, 00, 00, (int) $month, 1, 2000)) : LAN_CRON_41; // Month(s)
|
||||
$text .= "<br />";
|
||||
$text .= ($weekday != '*') ? LAN_CRON_54 ." ". e_date::strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s)
|
||||
$text .= ($weekday != '*') ? LAN_CRON_54 ." ". strftime("%A", mktime(00, 00, 00, 5, (int) $weekday, 2000)) : LAN_CRON_42; // Weekday(s)
|
||||
|
||||
|
||||
return "<a class='e-tip' href=''>".ADMIN_INFO_ICON."</a>
|
||||
@@ -711,7 +711,7 @@ class cron_admin_form_ui extends e_admin_form_ui
|
||||
{
|
||||
$sel = (in_array($i, $month)) ? "selected='selected'" : "";
|
||||
$diz = mktime(00, 00, 00, $i, 1, 2000);
|
||||
$text .= "<option value='$i' $sel>".e_date::strftime("%B", $diz)."</option>\n";
|
||||
$text .= "<option value='$i' $sel>".strftime("%B", $diz)."</option>\n";
|
||||
}
|
||||
$text .= "</select>
|
||||
|
||||
@@ -724,7 +724,7 @@ class cron_admin_form_ui extends e_admin_form_ui
|
||||
for ($i = 0; $i <= 6; $i++)
|
||||
{
|
||||
$sel = (in_array(strval($i), $weekday)) ? "selected='selected'" : "";
|
||||
$text .= "<option value='$i' $sel>".e_date::strftime("%A", mktime(00, 00, 00, 5, $i, 2000))."</option>\n";
|
||||
$text .= "<option value='$i' $sel>".strftime("%A", mktime(00, 00, 00, 5, $i, 2000))."</option>\n";
|
||||
}
|
||||
$text .= "</select>
|
||||
";
|
||||
|
@@ -787,26 +787,26 @@ $text .= "
|
||||
$def = strtotime('December 21, 2012 3:45pm');
|
||||
|
||||
$inputdate = array( // TODO add more formats
|
||||
"%A, %d %B, %Y" => e_date::strftime("%A, %d %B, %Y",$def),
|
||||
"%A, %d %b, %Y" => e_date::strftime("%A, %d %b, %Y",$def),
|
||||
"%a, %d %B, %Y" => e_date::strftime("%a, %d %B, %Y",$def),
|
||||
"%a, %d %b, %Y" => e_date::strftime("%a, %d %b, %Y",$def),
|
||||
"%A, %d %B, %Y" => strftime("%A, %d %B, %Y",$def),
|
||||
"%A, %d %b, %Y" => strftime("%A, %d %b, %Y",$def),
|
||||
"%a, %d %B, %Y" => strftime("%a, %d %B, %Y",$def),
|
||||
"%a, %d %b, %Y" => strftime("%a, %d %b, %Y",$def),
|
||||
|
||||
"%A, %B %d, %Y" => e_date::strftime("%A, %B %d, %Y",$def),
|
||||
"%A, %b %d, %Y" => e_date::strftime("%A, %b %d, %Y",$def),
|
||||
"%A, %b %d, %y" => e_date::strftime("%A, %b %d, %y",$def),
|
||||
"%A, %B %d, %Y" => strftime("%A, %B %d, %Y",$def),
|
||||
"%A, %b %d, %Y" => strftime("%A, %b %d, %Y",$def),
|
||||
"%A, %b %d, %y" => strftime("%A, %b %d, %y",$def),
|
||||
|
||||
"%B %d, %Y" => e_date::strftime("%B %d, %Y",$def),
|
||||
"%b %d, %Y" => e_date::strftime("%b %d, %Y",$def),
|
||||
"%b %d, %y" => e_date::strftime("%b %d, %y",$def),
|
||||
"%B %d, %Y" => strftime("%B %d, %Y",$def),
|
||||
"%b %d, %Y" => strftime("%b %d, %Y",$def),
|
||||
"%b %d, %y" => strftime("%b %d, %y",$def),
|
||||
|
||||
"%d %B, %Y" => e_date::strftime("%d %B, %Y",$def),
|
||||
"%d %b, %Y" => e_date::strftime("%d %b, %Y",$def),
|
||||
"%d %b, %y" => e_date::strftime("%d %b, %y",$def),
|
||||
"%d %B, %Y" => strftime("%d %B, %Y",$def),
|
||||
"%d %b, %Y" => strftime("%d %b, %Y",$def),
|
||||
"%d %b, %y" => strftime("%d %b, %y",$def),
|
||||
|
||||
"%Y-%m-%d" => e_date::strftime("%Y-%m-%d",$def),
|
||||
"%d-%m-%Y" => e_date::strftime("%d-%m-%Y",$def),
|
||||
"%m/%d/%Y" => e_date::strftime("%m/%d/%Y",$def)
|
||||
"%Y-%m-%d" => strftime("%Y-%m-%d",$def),
|
||||
"%d-%m-%Y" => strftime("%d-%m-%Y",$def),
|
||||
"%m/%d/%Y" => strftime("%m/%d/%Y",$def)
|
||||
);
|
||||
|
||||
|
||||
@@ -815,19 +815,19 @@ $text .= "
|
||||
|
||||
|
||||
|
||||
$inputtime["%I:%M %p"] = e_date::strftime("%I:%M %p",$def);
|
||||
$inputtime["%I:%M %p"] = strftime("%I:%M %p",$def);
|
||||
if(e107::getDate()->supported('P'))
|
||||
{
|
||||
$inputtime["%I:%M %P"] = e_date::strftime("%I:%M %P",$def);
|
||||
$inputtime["%I:%M %P"] = strftime("%I:%M %P",$def);
|
||||
}
|
||||
if(e107::getDate()->supported('l'))
|
||||
{
|
||||
$inputtime["%l:%M %p"] = e_date::strftime("%l:%M %p",$def);
|
||||
$inputtime["%l:%M %P"] = e_date::strftime("%l:%M %P",$def);
|
||||
$inputtime["%l:%M %p"] = strftime("%l:%M %p",$def);
|
||||
$inputtime["%l:%M %P"] = strftime("%l:%M %P",$def);
|
||||
}
|
||||
|
||||
$inputtime["%H:%M"] = e_date::strftime("%H:%M",$def);
|
||||
$inputtime["%H:%M:%S"] = e_date::strftime("%H:%M:%S",$def);
|
||||
$inputtime["%H:%M"] = strftime("%H:%M",$def);
|
||||
$inputtime["%H:%M:%S"] = strftime("%H:%M:%S",$def);
|
||||
|
||||
|
||||
|
||||
|
@@ -1305,7 +1305,7 @@ class admin_shortcodes extends e_shortcode
|
||||
<br /><br />
|
||||
<b>' .FOOTLAN_19. '</b>
|
||||
<br />
|
||||
' .e_date::strftime('%A %d %B %Y - %H:%M').
|
||||
' .strftime('%A %d %B %Y - %H:%M').
|
||||
'<br />';
|
||||
|
||||
return e107::getRender()->tablerender(FOOTLAN_13, $text, '', TRUE);
|
||||
|
@@ -80,10 +80,10 @@ trait StrptimeTrait
|
||||
|
||||
for ($i = 1; $i <= 12; $i++)
|
||||
{
|
||||
$k = e_date::strftime('%B', mktime(0, 0, 0, $i));
|
||||
$k = strftime('%B', mktime(0, 0, 0, $i));
|
||||
$fullmonth[$k] = $i;
|
||||
|
||||
$j = e_date::strftime('%b', mktime(0, 0, 0, $i));
|
||||
$j = strftime('%b', mktime(0, 0, 0, $i));
|
||||
$abrevmonth[$j] = $i;
|
||||
}
|
||||
|
||||
|
@@ -391,7 +391,7 @@ class CronParser
|
||||
|
||||
function getLastRan()
|
||||
{
|
||||
return explode(",", e_date::strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use
|
||||
return explode(",", strftime("%M,%H,%d,%m,%w,%Y", $this->lastRan)); //Get the values for now in a format we can use
|
||||
}
|
||||
|
||||
function getLastRanUnix()
|
||||
@@ -505,7 +505,7 @@ class CronParser
|
||||
}
|
||||
|
||||
//put the current time into an array
|
||||
$t = e_date::strftime("%M,%H,%d,%m,%w,%Y", time());
|
||||
$t = strftime("%M,%H,%d,%m,%w,%Y", time());
|
||||
$this->now = explode(",", $t);
|
||||
|
||||
$this->year = $this->now[5];
|
||||
|
@@ -37,17 +37,17 @@ class e_date
|
||||
|
||||
for ($i=1; $i < 8; $i++)
|
||||
{
|
||||
$day = e_date::strftime('%A', mktime(1, 1, 1, 1, $i, 2012));
|
||||
$day = strftime('%A', mktime(1, 1, 1, 1, $i, 2012));
|
||||
$dates['days'][] = $day;
|
||||
$dates['daysShort'][] = e_date::strftime('%a', mktime(1, 1, 1, 1, $i, 2012));
|
||||
$dates['daysShort'][] = strftime('%a', mktime(1, 1, 1, 1, $i, 2012));
|
||||
$dates['daysMin'][] = substr($day, 0, 2);
|
||||
}
|
||||
|
||||
|
||||
for ($i=1; $i < 13; $i++)
|
||||
{
|
||||
$dates['months'][] = e_date::strftime('%B', mktime(1, 1, 1, $i, 2, 2013));
|
||||
$dates['monthsShort'][] = e_date::strftime('%h', mktime(1, 1, 1, $i, 2, 2013));
|
||||
$dates['months'][] = strftime('%B', mktime(1, 1, 1, $i, 2, 2013));
|
||||
$dates['monthsShort'][] = strftime('%h', mktime(1, 1, 1, $i, 2, 2013));
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class e_date
|
||||
$marray = array();
|
||||
for ($i = 1; $i < 13; $i++)
|
||||
{
|
||||
$marray[$i] = e_date::strftime($val, mktime(1, 1, 1, $i, 1, 2000));
|
||||
$marray[$i] = strftime($val, mktime(1, 1, 1, $i, 1, 2000));
|
||||
}
|
||||
|
||||
return $marray;
|
||||
@@ -102,15 +102,15 @@ class e_date
|
||||
switch ($type)
|
||||
{
|
||||
case 'day-shortest': // eg. 'Tu'
|
||||
$days[] = substr(e_date::strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2);
|
||||
$days[] = substr(strftime('%a', mktime(1, 1, 1, 6, $i, 2014)), 0, 2);
|
||||
break;
|
||||
|
||||
case 'day-short': // eg. 'Tue'
|
||||
$days[] = e_date::strftime('%a', mktime(1, 1, 1, 6, $i, 2014));
|
||||
$days[] = strftime('%a', mktime(1, 1, 1, 6, $i, 2014));
|
||||
break;
|
||||
|
||||
default: // eg. 'Tuesday'
|
||||
$days[] = e_date::strftime('%A', mktime(1, 1, 1, 6, $i, 2014));
|
||||
$days[] = strftime('%A', mktime(1, 1, 1, 6, $i, 2014));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ class e_date
|
||||
break;
|
||||
}
|
||||
|
||||
$dateString = e_date::strftime($mask, $datestamp);
|
||||
$dateString = strftime($mask, $datestamp);
|
||||
|
||||
if (!e107::getParser()->isUTF8($dateString))
|
||||
{
|
||||
@@ -206,19 +206,6 @@ class e_date
|
||||
return $dateString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of {@see eShims::strftime()}
|
||||
*
|
||||
* See {@see eShims::strftime()} for more information.
|
||||
*
|
||||
* @param string $format The old {@see strftime()} format string
|
||||
* @param int|null $timestamp A Unix epoch timestamp. If null, defaults to the value of {@see time()}.
|
||||
* @return string Datetime formatted according to the provided arguments
|
||||
*/
|
||||
public static function strftime($format, $timestamp = null)
|
||||
{
|
||||
return eShims::strftime($format, $timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated - for internal use only.
|
||||
@@ -801,8 +788,8 @@ class e_date
|
||||
trigger_error('<b>' . __METHOD__ . ' is deprecated.</b> Use eShims::strptime() instead', E_USER_DEPRECATED); // NO LAN
|
||||
|
||||
$vals = eShims::strptime($str, $format); // PHP5 is more accurate than below.
|
||||
$vals['tm_amon'] = e_date::strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1));
|
||||
$vals['tm_fmon'] = e_date::strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1));
|
||||
$vals['tm_amon'] = strftime('%b', mktime(0, 0, 0, $vals['tm_mon'] + 1));
|
||||
$vals['tm_fmon'] = strftime('%B', mktime(0, 0, 0, $vals['tm_mon'] + 1));
|
||||
|
||||
return $vals;
|
||||
}
|
||||
@@ -882,7 +869,7 @@ class e_date
|
||||
// Evaluate the formats whilst suppressing any errors.
|
||||
foreach($strftimeFormats as $format => $description)
|
||||
{
|
||||
$strftimeValues[$format] = e_date::strftime("%{$format}");
|
||||
$strftimeValues[$format] = strftime("%{$format}");
|
||||
}
|
||||
|
||||
// Find the longest value.
|
||||
|
@@ -1452,7 +1452,7 @@ class banlistManager
|
||||
private function dateFormat($date)
|
||||
{
|
||||
if ($date == 0) return '0';
|
||||
return e_date::strftime('%Y%m%d_%H%M%S',$date);
|
||||
return strftime('%Y%m%d_%H%M%S',$date);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -632,7 +632,7 @@ class e_news_item extends e_front_model
|
||||
$params = array($val); //value is always the first callback argument
|
||||
$params = array_merge($params, explode(',', $parm['arg']));
|
||||
//should be done with date handler (awaiting for modifications)
|
||||
return e_date::strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
|
||||
return strftime(varset($parm['arg'], e107::getPref('shortdate')), $val);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -35,6 +35,15 @@ if (!function_exists('strptime'))
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('strftime'))
|
||||
{
|
||||
function strftime($format, $timestamp)
|
||||
{
|
||||
return eShims::strftime($format, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fix for exim missing.
|
||||
if(!function_exists('exif_imagetype'))
|
||||
{
|
||||
|
@@ -96,8 +96,8 @@ if (isset($_POST['clientsubmit']))
|
||||
{
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
$start_date = ($row['banner_startdate'] ? e_date::strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
|
||||
$end_date = ($row['banner_enddate'] ? e_date::strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
|
||||
$start_date = ($row['banner_startdate'] ? strftime("%d %B %Y", $row['banner_startdate']) : BANNERLAN_31);
|
||||
$end_date = ($row['banner_enddate'] ? strftime("%d %B %Y", $row['banner_enddate']) : BANNERLAN_31);
|
||||
|
||||
$scArray = array();
|
||||
$scArray['BANNER_TABLE_CLICKPERCENTAGE'] = ($row['banner_clicks'] && $row['banner_impressions'] ? round(($row['banner_clicks'] / $row['banner_impressions']) * 100)."%" : "-");
|
||||
|
@@ -140,7 +140,7 @@ class downloadCategory
|
||||
{
|
||||
$text = "<tr><td>".$cat['download_category_id']."</td><td>".$cat['download_category_parent']."</td><td>";
|
||||
$text .= $prefix.htmlspecialchars($cat['download_category_name']).$postfix."</td><td>".$cat['d_size']."</td>";
|
||||
$text .= "<td>".$cat['d_count']."</td><td>".$cat['d_requests']."</td><td>".e_date::strftime('%H:%M %d-%m-%Y',$cat['d_last'])."</td>";
|
||||
$text .= "<td>".$cat['d_count']."</td><td>".$cat['d_requests']."</td><td>".strftime('%H:%M %d-%m-%Y',$cat['d_last'])."</td>";
|
||||
$text .= "</tr>";
|
||||
return $text;
|
||||
}
|
||||
|
@@ -727,14 +727,14 @@ class listclass
|
||||
if($thisday == $current_day)
|
||||
{
|
||||
$datepreftoday = $this->list_pref[$this->mode."_datestyletoday"];
|
||||
return e_date::strftime($datepreftoday, $datestamp);
|
||||
return strftime($datepreftoday, $datestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//else use default date style
|
||||
$datepref = $this->list_pref[$this->mode."_datestyle"];
|
||||
return e_date::strftime($datepref, $datestamp);
|
||||
return strftime($datepref, $datestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1889,10 +1889,10 @@ class news_front
|
||||
|
||||
|
||||
// render new date header if pref selected ...
|
||||
$thispostday = e_date::strftime("%j", $news['news_datestamp']);
|
||||
$thispostday = strftime("%j", $news['news_datestamp']);
|
||||
if ($newpostday != $thispostday && (isset($this->pref['news_newdateheader']) && $this->pref['news_newdateheader']))
|
||||
{
|
||||
echo "<div class='".DATEHEADERCLASS."'>".e_date::strftime("%A %d %B %Y", $news['news_datestamp'])."</div>";
|
||||
echo "<div class='".DATEHEADERCLASS."'>".strftime("%A %d %B %Y", $news['news_datestamp'])."</div>";
|
||||
}
|
||||
$newpostday = $thispostday;
|
||||
$news['category_id'] = $news['news_category'];
|
||||
|
@@ -37,13 +37,13 @@ function defined($constant_name)
|
||||
* @param array|string|int $locales
|
||||
* @param string ...$rest
|
||||
* @return false|string
|
||||
*/
|
||||
*//*
|
||||
function setlocale($category, $locales, ...$rest)
|
||||
{
|
||||
if (e_dateAlternateTest::$alternate_locale) return 'nl_NL';
|
||||
|
||||
return \setlocale($category, $locales, ...$rest);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
class e_dateAlternateTest extends \e_dateTest
|
||||
@@ -76,18 +76,23 @@ class e_dateAlternateTest extends \e_dateTest
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
setlocale(LC_ALL,'nl_NL.utf8', 'nl');
|
||||
$actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'long');
|
||||
$expected = 'maandag 05 februari 2018 - 12:45:03';
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
$actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'inputtime');
|
||||
$expected = '12:45 P.M.';
|
||||
setlocale(LC_ALL,'es_SP.utf8', 'es');
|
||||
|
||||
$actual = $this->dateObj->convert_date(mktime(12, 45, 03, 2, 5, 2018), 'inputdate');
|
||||
$expected = 'lunes, 05 feb, 2018';
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
finally
|
||||
{
|
||||
self::$alternate_locale = false;
|
||||
setlocale(LC_ALL, 'en_GB.UTF-8', 'en_GB.utf8', 'en');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user