- function getMonth($month) {
- $date = "{MONTH}";
- if (eregi("jan|january", $month, $tmp))
- $date = "Jan";
- else if (eregi("feb|february|febuary", $month, $tmp))
- $date = "Feb";
- else if (eregi("mar|march", $month, $tmp))
- $date = "Mar";
- else if (eregi("apr|april", $month, $tmp))
- $date = "Apr";
- else if (eregi("may", $month, $tmp))
- $date = "May";
- else if (eregi("jun|june", $month, $tmp))
- $date = "Jun";
- else if (eregi("jul|july", $month, $tmp))
- $date = "Jul";
- else if (eregi("aug|august", $month, $tmp))
- $date = "Aug";
- else if (eregi("sep|sept|september", $month, $tmp))
- $date = "Sep";
- else if (eregi("oct|october", $month, $tmp))
- $date = "Oct";
- else if (eregi("nov|november", $month, $tmp))
- $date = "Nov";
- else if (eregi("dec|december", $month, $tmp))
- $date = "Dec";
-
- return $date;
- }
-
- function getYear($year) {
- return $year;
- }
-
- function getLongDateString($stamp) {
- return date("D, F j, Y g:i a", $stamp);
- }
-
- function getDateString($stamp) {
- $now = time();
- $midnight = $now - ($now % 86400) - date("Z", $now);
-
- 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);
- }
- }
-
- function getTimeStamp($dateParts) {
- /** $dateParts[0] == <day of week> Mon, Tue, Wed
- ** $dateParts[1] == <day of month> 23
- ** $dateParts[2] == <month> Jan, Feb, Mar
- ** $dateParts[3] == <year> 1999
- ** $dateParts[4] == <time> 18:54:23 (HH:MM:SS)
- ** $dateParts[5] == <from GMT> +0100
- ** $dateParts[6] == <zone> (EDT)
- **
- ** NOTE: In RFC 822, it states that <day of week> is optional.
- ** In that case, dateParts[0] would be the <day of month>
- ** and everything would be bumped up one.
- **/
+function getTimeStamp($dateParts) {
+ /** $dateParts[0] == <day of week> Mon, Tue, Wed
+ ** $dateParts[1] == <day of month> 23
+ ** $dateParts[2] == <month> Jan, Feb, Mar
+ ** $dateParts[3] == <year> 1999
+ ** $dateParts[4] == <time> 18:54:23 (HH:MM:SS)
+ ** $dateParts[5] == <from GMT> +0100
+ ** $dateParts[6] == <zone> (EDT)
+ **
+ ** NOTE: In RFC 822, it states that <day of week> is optional.
+ ** In that case, dateParts[0] would be the <day of month>
+ ** and everything would be bumped up one.
+ **/
+
+ /*
+ * Simply check to see if the first element in the dateParts
+ * array is an integer or not.
+ * Since the day of week is optional, this check is needed.
+ *
+ * The old code used eregi('mon|tue|wed|thu|fri|sat|sun',
+ * $dateParts[0], $tmp) to find if the first element was the
+ * day of week or day of month. This is an expensive call
+ * (processing time) to have inside a loop. Doing it this way
+ * saves quite a bit of time for large mailboxes.
+ *
+ * It is also quicker to call explode only once rather than
+ * the 3 times it was getting called by calling the functions
+ * getHour, getMinute, and getSecond.
+ */