1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Migrate away from strftime

This commit is contained in:
Sara Golemon
2021-07-05 14:47:20 +00:00
parent 22f0d88721
commit ae006c3288
4 changed files with 35 additions and 17 deletions

44
cal.php
View File

@@ -129,25 +129,43 @@ $bom = mktime(0, 0, 1, $cm, 1, $cy);
$eom = mktime(0, 0, 1, $cm+1, 0, $cy);
// Link to previous month (but do not link to too early dates)
$lm = mktime(0, 0, 1, $cm, 0, $cy);
if (valid_year(date("Y", $lm))) {
$prev_link = '<a href="/cal.php' . strftime('?cm=%m&amp;cy=%Y">%B, %Y</a>', $lm);
} else {
$prev_link = '&nbsp;';
}
$prev_link = (function() use ($cm, $cy) {
$lm = mktime(0, 0, 1, $cm, 0, $cy);
$year = date('Y', $lm);
if (!valid_year($year)) {
return '&nbsp;';
}
$month = date('m', $lm);
$monthName = date('F', $lm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
})();
// Link to next month (but do not link to too early dates)
$nm = mktime(0, 0, 1, $cm+1, 1, $cy);
if (valid_year(date("Y", $nm))) {
$next_link = '<a href="/cal.php' . strftime('?cm=%m&amp;cy=%Y">%B, %Y</a>', $nm);
} else {
$next_link = '&nbsp;';
}
$next_link = (function() use ($cm, $cy) {
$nm = mktime(0, 0, 1, $cm+1, 1, $cy);
$year = date('Y', $nm);
if (!valid_year($year)) {
return '&nbsp;';
}
$month = date('m', $nm);
$monthName = date('F', $nm);
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
urlencode($month),
urlencode($year),
htmlentities($monthName),
htmlentities($year));
})();
// Print out navigation links for previous and next month
echo '<br><table id="calnav" width="100%" border="0" cellspacing="0" cellpadding="3">',
"\n<tr>", '<td align="left" width="33%">', $prev_link, '</td>',
'<td align="center" width="33%">', strftime('<b>%B, %Y</b></td>', $bom),
'<td align="center" width="33%"><b>', htmlentities(date('F, Y', $bom)), '</b></td>',
'<td align="right" width="33%">', $next_link, "</td></tr>\n</table>\n";
// Begin the calendar table

View File

@@ -295,7 +295,7 @@ function display_event($event, $include_date = 1)
// Weekday names array
for ($i = 1; $i <= 7; $i++) {
$days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i, 2012));
$days[$i] = date('l', mktime(12, 0, 0, 4, $i, 2012));
}
// Recurring possibilities

View File

@@ -91,7 +91,7 @@ site_header("Information About This PHP Mirror Site", array("current" => "commun
<h2>Mirror Status</h2>
<ul>
<li>The site was last updated at <?php echo strftime("%c %Z", $LAST_UPDATED); ?></li>
<li>The site was last updated at <?php echo date('r', $LAST_UPDATED); ?></li>
</ul>
<?php site_footer(); ?>

View File

@@ -152,10 +152,10 @@ if (count($errors)) { display_errors($errors); }
// Generate days and months arrays for form
for ($i = 1; $i <= 7; $i++) {
$days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i));
$days[$i] = date('l', mktime(12, 0, 0, 4, $i));
}
for ($i = 1; $i <= 12; $i++) {
$months[$i] = strftime('%B', mktime(12, 0, 0, $i, 1));
$months[$i] = date('F', mktime(12, 0, 0, $i, 1));
}
// Possibilities to recur