Added date translation to local time
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 19 Dec 1999 13:52:56 +0000 (13:52 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 19 Dec 1999 13:52:56 +0000 (13:52 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@87 7612ce4b-ef26-0410-bec9-ea0150e637f0

ChangeLog
functions/date.php
functions/mailbox_display.php
functions/mime.php

index fe5c2d4ae8c3ff0ac7d59b44e325c91a0437f4e5..476ff3b32e9d988555fa0ff40319c22859e888f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Version 0.1.2  -- 
+----------------------------------
+- Date translation to local time
+
+Version 0.1.1  -- December 16, 1999
+-----------------------------------
+- Reworked all the IMAP functions to make them RFC 2060 compliant
+  (should work with all IMAP servers)
+- Added color customization
+- Sorted folder list (on left bar)
+- Added MUCH better error correction and notification
+
 Version 0.1 -- December 14, 1999
 --------------------------------
 - Message composing (with to, cc, bcc)
index b46802ae69d44dbb55b3917e3aa971db3d4724dd..e1d9c388ccaf0016d3497d85995d0204554e66ea 100644 (file)
       return $date;
    }
 
+   // corrects a time stamp to be the local time
+   function getGMTSeconds($stamp, $gmt) {
+      if (substr($gmt, 0, 1) == "-") {
+         $neg = true;
+         $gmt = substr($gmt, 1, strlen($gmt));
+      } else if (substr($gmt, 0, 1) == "+") {
+         $neg = false;
+         $gmt = substr($gmt, 1, strlen($gmt));
+      } else
+         $neg = false;
+
+      $gmt = substr($gmt, 0, 2);
+      $gmt = $gmt * 3600;
+      if ($neg == true)
+         $gmt = "-$gmt";
+      else
+         $gmt = "+$gmt";
+
+      /** now find what the server is at **/
+      $current = date("Z", time());
+
+      $stamp = (int)$stamp - (int)$gmt + (int)$current;
+
+      return $stamp;
+   }
+
    function getHour($hour) {
       $time = explode(":", $hour);
       return $time[0];
       return $year;
    }
 
-   function getDateString($dateParts) {
+   function getLongDateString($stamp) {
+      return date("D, F j, Y g:i a", $stamp);
+   }
+
+   function getDateString($stamp) {
+      return date("M j, Y", $stamp);
+   }
+
+   function getTimeStamp($dateParts) {
       /** $dateParts[0] == <day of week>   Mon, Tue, Wed
        ** $dateParts[1] == <day of month>  23
        ** $dateParts[2] == <month>         Jan, Feb, Mar
        **        and everything would be bumped up one.
        **/
 
-      /* if the first part is a day */
-      if (eregi("mon|tue|wed|thu|fri|sat|sun", trim($dateParts[0]), $tmp)) {
-         $dateParts[0] = getDayOfWeek(trim($dateParts[0]));
-         $dateParts[1] = getDayOfMonth(trim($dateParts[1]));
-         $dateParts[2] = getMonth(trim($dateParts[2]));
-         $dateParts[3] = getYear(trim($dateParts[3]));
-         return "$dateParts[2] $dateParts[1], $dateParts[3]";
-      }
-      $dateParts[0] = getDayOfMonth(trim($dateParts[0]));
-      $dateParts[1] = getMonth(trim($dateParts[1]));
-      $dateParts[2] = getYear(trim($dateParts[2]));
-      return "$dateParts[1] $dateParts[0], $dateParts[2]";
-   }
-
-   function getTimeStamp($dateParts) {
       if (eregi("mon|tue|wed|thu|fri|sat|sun", $dateParts[0], $tmp)) {
          $d[0] = getHour(trim($dateParts[4]));
          $d[1] = getMinute(trim($dateParts[4]));
          $d[3] = getMonthNum(trim($dateParts[2]));
          $d[4] = getDayOfMonth(trim($dateParts[1]));
          $d[5] = getYear(trim($dateParts[3]));
-         return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
+         return getGMTSeconds(mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]), $dateParts[5]);
       }
       $d[0] = getHour(trim($dateParts[3]));
       $d[1] = getMinute(trim($dateParts[3]));
       $d[3] = getMonthNum(trim($dateParts[1]));
       $d[4] = getDayOfMonth(trim($dateParts[0]));
       $d[5] = getYear(trim($dateParts[2]));
-      return mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]);
-   }
-
-   function getLongDateString($stamp) {
-      $dateArray = getDate($stamp);
-
-      if ($dateArray["hours"] >= 12) {
-         $am_pm = "p.m.";
-      } else {
-         $am_pm = "a.m.";
-      }
-
-      if ($dateArray["hours"] >= 13) {
-         $dateArray["hours"] = $dateArray["hours"] - 12;
-      }
-
-      $dateParts[0] = getDayOfMonth($dateArray["mday"]);
-      $dateParts[1] = getMonth($dateArray["month"]);
-      $dateParts[2] = getYear($dateArray["year"]);
-      $dateParts[3] = $dateArray["hours"]; // hour
-      $dateParts[4] = getMinutes($dateArray["minutes"]); // minute
-
-      return "$dateParts[1] $dateParts[0], $dateParts[2] at $dateParts[3]:$dateParts[4] $am_pm";
+      return getGMTSeconds(mktime($d[0], $d[1], $d[2], $d[3], $d[4], $d[5]), $dateParts[4]);
    }
 ?>
index 435facc0fb441c27fb7a3f26383020c281d2e8f8..dfc852dec7a275f4c61f0644030c018b1e3664c2 100644 (file)
@@ -45,7 +45,7 @@
          $tmpdate = explode(" ", trim($date[$j]));
 
          $messages[$j]["TIME_STAMP"] = getTimeStamp($tmpdate);
-         $messages[$j]["DATE_STRING"] = getDateString($tmpdate);
+         $messages[$j]["DATE_STRING"] = getDateString($messages[$j]["TIME_STAMP"]);
          $messages[$j]["ID"] = $j+1;
          $messages[$j]["FROM"] = getSenderName($from[$j]);
          $messages[$j]["SUBJECT"] = $subject[$j];
index 6182250fe3b2421c19e2707238dfcbf97bb72d5d..dc9a6854058d3daadc2b76bbf7205f957bf18ead 100644 (file)
@@ -6,7 +6,7 @@
 
 
    function decodeMime($body, $bound, $type0, $type1) {
-//      echo "$type0/$type1<BR>";
+      echo "$type0/$type1<BR>";
       if ($type0 == "multipart") {
          if ($body[0] == "")
             $i = 1;
@@ -42,7 +42,7 @@
 
    /** This gets one entity's properties **/
    function getEntity($body, $bound, $type0, $type1, $encoding, $charset) {
-//      echo "$type0/$type1<BR>";
+      echo "$type0/$type1<BR>";
       $msg[0]["TYPE0"] = $type0;
       $msg[0]["TYPE1"] = $type1;
       $msg[0]["ENCODING"] = $encoding;
             $msg[0]["BODY"] = $body;
          } else {
             $msg[0]["PRIORITY"] = 1;
-            $msg[0]["BODY"][0] = "<B><FONT COLOR=DD0000>This attachment is an unknown text format:  $type0/$type1</FONT></B>";
+            $msg[0]["BODY"][0] = "This entity is of an unknown format.  Doing my best to display anyway...<BR><BR>";
+            for ($p = 1;$p < count($body);$p++) {
+               $q = $p - 1;
+               $msg[0]["BODY"][$p] = $body[$q];
+            }
          }
       } else if ($type0 == "image") {
          $msg[0]["BODY"][0] = "<B><FONT COLOR=DD0000>This is an image.  Squirrelmail currently cannot decode images.</FONT></B>";