Skip to content

Commit ae006c3

Browse files
committed
Migrate away from strftime
1 parent 22f0d88 commit ae006c3

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

cal.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,43 @@
129129
$eom = mktime(0, 0, 1, $cm+1, 0, $cy);
130130

131131
// Link to previous month (but do not link to too early dates)
132-
$lm = mktime(0, 0, 1, $cm, 0, $cy);
133-
if (valid_year(date("Y", $lm))) {
134-
$prev_link = '<a href="/cal.php' . strftime('?cm=%m&amp;cy=%Y">%B, %Y</a>', $lm);
135-
} else {
136-
$prev_link = '&nbsp;';
137-
}
132+
$prev_link = (function() use ($cm, $cy) {
133+
$lm = mktime(0, 0, 1, $cm, 0, $cy);
134+
$year = date('Y', $lm);
135+
if (!valid_year($year)) {
136+
return '&nbsp;';
137+
}
138+
139+
$month = date('m', $lm);
140+
$monthName = date('F', $lm);
141+
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
142+
urlencode($month),
143+
urlencode($year),
144+
htmlentities($monthName),
145+
htmlentities($year));
146+
})();
138147

139148
// Link to next month (but do not link to too early dates)
140-
$nm = mktime(0, 0, 1, $cm+1, 1, $cy);
141-
if (valid_year(date("Y", $nm))) {
142-
$next_link = '<a href="/cal.php' . strftime('?cm=%m&amp;cy=%Y">%B, %Y</a>', $nm);
143-
} else {
144-
$next_link = '&nbsp;';
145-
}
149+
$next_link = (function() use ($cm, $cy) {
150+
$nm = mktime(0, 0, 1, $cm+1, 1, $cy);
151+
$year = date('Y', $nm);
152+
if (!valid_year($year)) {
153+
return '&nbsp;';
154+
}
155+
156+
$month = date('m', $nm);
157+
$monthName = date('F', $nm);
158+
return sprintf('<a href="/cal.php?cm=%s&amp;cy=%s">%s, %s</a>',
159+
urlencode($month),
160+
urlencode($year),
161+
htmlentities($monthName),
162+
htmlentities($year));
163+
})();
146164

147165
// Print out navigation links for previous and next month
148166
echo '<br><table id="calnav" width="100%" border="0" cellspacing="0" cellpadding="3">',
149167
"\n<tr>", '<td align="left" width="33%">', $prev_link, '</td>',
150-
'<td align="center" width="33%">', strftime('<b>%B, %Y</b></td>', $bom),
168+
'<td align="center" width="33%"><b>', htmlentities(date('F, Y', $bom)), '</b></td>',
151169
'<td align="right" width="33%">', $next_link, "</td></tr>\n</table>\n";
152170

153171
// Begin the calendar table

include/layout.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ function display_event($event, $include_date = 1)
295295

296296
// Weekday names array
297297
for ($i = 1; $i <= 7; $i++) {
298-
$days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i, 2012));
298+
$days[$i] = date('l', mktime(12, 0, 0, 4, $i, 2012));
299299
}
300300

301301
// Recurring possibilities

mirror.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<h2>Mirror Status</h2>
9292

9393
<ul>
94-
<li>The site was last updated at <?php echo strftime("%c %Z", $LAST_UPDATED); ?></li>
94+
<li>The site was last updated at <?php echo date('r', $LAST_UPDATED); ?></li>
9595
</ul>
9696

9797
<?php site_footer(); ?>

submit-event.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@
152152

153153
// Generate days and months arrays for form
154154
for ($i = 1; $i <= 7; $i++) {
155-
$days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i));
155+
$days[$i] = date('l', mktime(12, 0, 0, 4, $i));
156156
}
157157
for ($i = 1; $i <= 12; $i++) {
158-
$months[$i] = strftime('%B', mktime(12, 0, 0, $i, 1));
158+
$months[$i] = date('F', mktime(12, 0, 0, $i, 1));
159159
}
160160

161161
// Possibilities to recur

0 commit comments

Comments
 (0)