From 0f1835f3980145bab8afef56f9caa59502b82bd4 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sun, 19 Dec 1999 13:52:56 +0000 Subject: [PATCH] Added date translation to local time git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@87 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 12 ++++++ functions/date.php | 77 +++++++++++++++++------------------ functions/mailbox_display.php | 2 +- functions/mime.php | 10 +++-- 4 files changed, 57 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe5c2d4a..476ff3b3 100644 --- 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) diff --git a/functions/date.php b/functions/date.php index b46802ae..e1d9c388 100644 --- a/functions/date.php +++ b/functions/date.php @@ -36,6 +36,32 @@ 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]; @@ -139,7 +165,15 @@ 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] == Mon, Tue, Wed ** $dateParts[1] == 23 ** $dateParts[2] == Jan, Feb, Mar @@ -153,21 +187,6 @@ ** 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])); @@ -175,7 +194,7 @@ $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])); @@ -183,28 +202,6 @@ $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]); } ?> diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 435facc0..dfc852de 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -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]; diff --git a/functions/mime.php b/functions/mime.php index 6182250f..dc9a6854 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -6,7 +6,7 @@ function decodeMime($body, $bound, $type0, $type1) { -// echo "$type0/$type1
"; + echo "$type0/$type1
"; 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
"; + echo "$type0/$type1
"; $msg[0]["TYPE0"] = $type0; $msg[0]["TYPE1"] = $type1; $msg[0]["ENCODING"] = $encoding; @@ -59,7 +59,11 @@ $msg[0]["BODY"] = $body; } else { $msg[0]["PRIORITY"] = 1; - $msg[0]["BODY"][0] = "This attachment is an unknown text format: $type0/$type1"; + $msg[0]["BODY"][0] = "This entity is of an unknown format. Doing my best to display anyway...

"; + for ($p = 1;$p < count($body);$p++) { + $q = $p - 1; + $msg[0]["BODY"][$p] = $body[$q]; + } } } else if ($type0 == "image") { $msg[0]["BODY"][0] = "This is an image. Squirrelmail currently cannot decode images."; -- 2.25.1