When you reload signout.php you get an error that you have to be logged in
[squirrelmail.git] / functions / date.php
index 2f65cc6cc3a8aa311cdc33082c98481f0ad958ff..65db2003b21b90f591e2a043b42d78b47242a539 100644 (file)
@@ -11,8 +11,9 @@
  *       <Tue,> 29 Jun 1999 09:52:11 -0500 (EDT)
  * (as specified in RFC 822) -- 'Tue' is optional
  *
- * $Id$
+ * @version $Id$
  * @package squirrelmail
+ * @subpackage date
  */
 
 /** Load up some useful constants */
@@ -289,9 +290,9 @@ function date_intl( $date_format, $stamp ) {
     $aParts = explode('#',$ret);
     $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]),
                                                           getMonthAbrv($aParts[1]),
-                                                         getMonthName($aParts[1]),
-                                                         getDayName($aParts[0])),
-                                                         $aParts[2]);
+                                                          getMonthName($aParts[1]),
+                                                          getDayName($aParts[0])),
+                                                          $aParts[2]);
     return( $ret );
 }
 
@@ -348,8 +349,16 @@ function getDateString( $stamp ) {
     if ($invert_time) {
         $dateZ = - $dateZ;
     }
+
+    // calculate when it was midnight and when it will be,
+    // in order to display dates differently if they're 'today'
     $midnight = $now - ($now % 86400) - $dateZ;
-    $nextmid = $midnight + 86400 - $dateZ;
+    // this is to correct if after calculations midnight is more than
+    // one whole day away.
+    if ($now - $midnight > 86400) {
+        $midnight += 86400;
+    }
+    $nextmid = $midnight + 86400;
 
     if (($show_full_date == 1) || ($nextmid < $stamp)) {
         $date_format = _("M j, Y");