Commit:    cad8f0789a3abb94a7271ac51f32edbf09fd3410
Author:    Sherif Ramadan <[email protected]>         Fri, 22 Nov 2013 18:44:21 
-0500
Parents:   db6b369287a9b1f2a6778ffedc618a3174341c52
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=cad8f0789a3abb94a7271ac51f32edbf09fd3410

Log:
Make the EOL dates slightly more readable.

Changed paths:
  M  eol.php


Diff:
diff --git a/eol.php b/eol.php
index 65b783f..eb867cf 100644
--- a/eol.php
+++ b/eol.php
@@ -36,27 +36,63 @@ site_header('Unsupported Branches');
                </tr>
        </thead>
        <tbody>
-               <?php foreach (get_eol_branches() as $major => $branches): ?>
-                       <?php foreach ($branches as $branch => $detail): ?>
-                               <tr>
-                                       <td><?php echo 
htmlspecialchars($branch); ?></td>
-                                       <td>
-                                               <?php echo date('j M Y', 
$detail['date']); ?>
-                                       </td>
-                                       <td>
-                                               <?php echo number_format($ago = 
floor((time() - $detail['date']) / 86400)); ?>
-                                               day<?php echo ($ago != 1 ? 's' 
: ''); ?> ago
-                                       </td>
-                                       <td>
-                                               <a href="/releases/#<?php echo 
htmlspecialchars($detail['version']); ?>">
-                                                       <?php echo 
htmlspecialchars($detail['version']); ?>
-                                               </a>
-                                       </td>
-                                       <td>
-                                               <?php echo 
isset($BRANCH_NOTES[$branch]) ? $BRANCH_NOTES[$branch] : ''; ?>
+               <?php foreach (get_eol_branches() as $major => $branches):
+
+                               foreach ($branches as $branch => $detail) {
+                                       try {
+                                               $now  = new DateTime;
+                                               $then = new 
DateTime($detail['date']);
+                                               $diff = $now->diff($then);
+                                               $times = array();
+                                               if ($diff->y) {
+                                                       $times[] = 
array($diff->y,'year');
+                                                       if ($diff->m) {
+                                                       $times[] = 
array($diff->m,'month');
+                                                       }
+                                               } elseif ($diff->m) {
+                                                       $times[] = 
array($diff->m,'year');
+                                               } elseif ($diff->d) {
+                                                       $times[] = 
array($diff->d,'year');
+                                               } else {
+                                                       $eolPeriod = 'moments 
ago...';
+                                               }
+                                               if ($times) {
+                                                       $eolPeriod = implode(', 
', 
+                                                                               
                                array_map(
+                                                                               
                                        function($t) {
+                                                                               
                                                foreach ($t as $T) {
+                                                                               
                                                        return "$t[0] $t[1]" .
+                                                                               
                                                                        ($t[1] 
!= 1 ? 's' : '');
+                                                                               
                                                }
+                                                                               
                                        },
+                                                                               
                                        $times
+                                                                               
                                )
+                                                                               
                ) . " ago";
+                                               } else {
+                                                       $eolPeriod = 
'uknown...';
+                                               }
+                                       } catch(Exception $e) {
+                                               $eolPeriod = 'uknown...';
+                                       }
+               ?>
+                                       <tr>
+                                               <td><?php echo 
htmlspecialchars($branch); ?></td>
+                                               <td>
+                                                       <?php echo date('j M 
Y', $detail['date']); ?>
+                                               </td>
+                                               <td>
+                                                       <em><?php echo 
$eolPeriod ?></em>
+                                               </td>
+                                               <td>
+                                                       <a 
href="/releases/#<?php echo htmlspecialchars($detail['version']); ?>">
+                                                               <?php echo 
htmlspecialchars($detail['version']); ?>
+                                                       </a>
+                                               </td>
+                                               <td>
+                                                       <?php echo 
isset($BRANCH_NOTES[$branch]) ? $BRANCH_NOTES[$branch] : ''; ?>
                                        </td>
                                </tr>
-                       <?php endforeach; ?>
+                           <?php } ?>
                <?php endforeach; ?>
        </tbody>
 </table>


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

Reply via email to