X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fdate.php;h=7276811aea3bede464e2fd9c752125f8c9c0cd70;hp=c258fc941f5c283bce789b5d238ac9a0b0737d63;hb=a3439b271e1b5fa7e61362970dbbcc5bfc75e5b1;hpb=245a6892bf5c780904ef9677f24d624ea17e0749 diff --git a/functions/date.php b/functions/date.php index c258fc94..7276811a 100644 --- a/functions/date.php +++ b/functions/date.php @@ -1,138 +1,290 @@ 29 Jun 1999 09:52:11 -0500 (EDT) - ** (as specified in RFC 822) -- "Tue" is optional - ** - ** $Id$ - **/ - $date_php = true; - - // corrects a time stamp to be the local time - function getGMTSeconds($stamp, $gmt) { - global $invert_time; - if (($gmt == "Pacific") || ($gmt == "PST")) - $gmt = "-0800"; - else if (($gmt == "EDT")) - $gmt = "-0400"; - else if (($gmt == "Eastern") || ($gmt == "EST") || ($gmt == "CDT")) - $gmt = "-0500"; - else if (($gmt == "Central") || ($gmt == "CST") || ($gmt == "MDT")) - $gmt = "-0600"; - else if (($gmt == "Mountain") || ($gmt == "MST") || ($gmt == "PDT")) - $gmt = "-0700"; - else if ($gmt == "BST") - $gmt = "+0100"; - else if ($gmt == "EET") - $gmt = "+0200"; - else if ($gmt == "GMT") - $gmt = "+0000"; - else if ($gmt == "HKT") - $gmt = "+0800"; - else if ($gmt == "IST") - $gmt = "+0200"; - else if ($gmt == "JST") - $gmt = "+0900"; - else if ($gmt == "MET") - $gmt = "+0100"; - else if ($gmt == "MET DST" || $gmt == "METDST") - $gmt = "+0200"; - - 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()); - if ($invert_time) - $current = - $current; - $stamp = (int)$stamp - (int)$gmt + (int)$current; - - return $stamp; - } +/** + * date.php + * + * Copyright (c) 1999-2001 The SquirrelMail Development Team + * Licensed under the GNU GPL. For full terms see the file COPYING. + * + * Takes a date and parses it into a usable format. The form that a + * date SHOULD arrive in is: + * 29 Jun 1999 09:52:11 -0500 (EDT) + * (as specified in RFC 822) -- 'Tue' is optional + * + * $Id$ + */ - function getLongDateString($stamp) { - return date("D, F j, Y g:i a", $stamp); - } +require_once( '../functions/constants.php' ); - function getDateString($stamp) { - global $invert_time; - $now = time(); - $dateZ = date("Z", $now); - if ($invert_time) - $dateZ = - $dateZ; - $midnight = $now - ($now % 86400) - $dateZ; - - if ($midnight < $stamp) { - // Today - return date("g:i a", $stamp); - } else if ($midnight - (60 * 60 * 24 * 6) < $stamp) { - // This week - return date("D, g:i a", $stamp); - } else { - // before this week - return date("M j, Y", $stamp); - } - } +// corrects a time stamp to be the local time +function getGMTSeconds($stamp, $gmt) { + global $invert_time; + if (($gmt == 'Pacific') || ($gmt == 'PST')) { + $gmt = '-0800'; + } else if (($gmt == 'EDT')) { + $gmt = '-0400'; + } else if (($gmt == 'Eastern') || ($gmt == 'EST') || ($gmt == 'CDT')) { + $gmt = '-0500'; + } else if (($gmt == 'Central') || ($gmt == 'CST') || ($gmt == 'MDT')) { + $gmt = '-0600'; + } else if (($gmt == 'Mountain') || ($gmt == 'MST') || ($gmt == 'PDT')) { + $gmt = '-0700'; + } else if ($gmt == 'BST') { + $gmt = '+0100'; + } else if ($gmt == 'EET') { + $gmt = '+0200'; + } else if ($gmt == 'GMT') { + $gmt = '+0000'; + } else if ($gmt == 'HKT') { + $gmt = '+0800'; + } else if ($gmt == 'IST') { + $gmt = '+0200'; + } else if ($gmt == 'JST') { + $gmt = '+0900'; + } else if ($gmt == 'KST') { + $gmt = "+0900"; + } else if ($gmt == 'MET') { + $gmt = '+0100'; + } else if ($gmt == 'MET DST' || $gmt == 'METDST') { + $gmt = '+0200'; + } + + 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()); + if ($invert_time) { + $current = - $current; + } + $stamp = (int)$stamp - (int)$gmt + (int)$current; + + return $stamp; +} - function getTimeStamp($dateParts) { - /** $dateParts[0] == Mon, Tue, Wed - ** $dateParts[1] == 23 - ** $dateParts[2] == Jan, Feb, Mar - ** $dateParts[3] == 1999 - ** $dateParts[4] ==