Author: Sara Golemon (sgolemon)
Date: 2021-07-05T14:55:45Z

Commit: 
https://github.com/php/web-php/commit/ae006c328851ef3ed7410f3117d28b76bc3262de
Raw diff: 
https://github.com/php/web-php/commit/ae006c328851ef3ed7410f3117d28b76bc3262de.diff

Migrate away from strftime

Changed paths:
  M  cal.php
  M  include/layout.inc
  M  mirror.php
  M  submit-event.php


Diff:

diff --git a/cal.php b/cal.php
index 8d27de4c7..ed02e43d0 100644
--- a/cal.php
+++ b/cal.php
@@ -129,25 +129,43 @@
 $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
diff --git a/include/layout.inc b/include/layout.inc
index 1b2c97c25..fa61262e7 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -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
diff --git a/mirror.php b/mirror.php
index 38518cb08..4c25f76f8 100644
--- a/mirror.php
+++ b/mirror.php
@@ -91,7 +91,7 @@
 <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(); ?>
diff --git a/submit-event.php b/submit-event.php
index ba041664d..055c694d6 100644
--- a/submit-event.php
+++ b/submit-event.php
@@ -152,10 +152,10 @@
 
 // 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

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to