- // 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.
- //
- if (! isset($dateParts[1])) $dateParts[1] = '';
- if (! isset($dateParts[2])) $dateParts[2] = '';
- if (! isset($dateParts[3])) $dateParts[3] = '';
- if (! isset($dateParts[4])) $dateParts[4] = '';
- if (! isset($dateParts[5])) $dateParts[5] = '';
- if (intval(trim($dateParts[0])) > 0) {
- $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' .
- $dateParts[2] . ' ' . $dateParts[3];
- return getGMTSeconds(strtotime($string), $dateParts[4]);
- }
- $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' .
- $dateParts[2] . ' ' . $dateParts[3] . ' ' . $dateParts[4];
- if (isset($dateParts[5]))
- return getGMTSeconds(strtotime($string), $dateParts[5]);
- else
- return getGMTSeconds(strtotime($string), '');
- }
+ if (! isset($dateParts[1])) {
+ $dateParts[1] = '';
+ }
+ if (! isset($dateParts[2])) {
+ $dateParts[2] = '';
+ }
+ if (! isset($dateParts[3])) {
+ $dateParts[3] = '';
+ }
+ if (! isset($dateParts[4])) {
+ $dateParts[4] = '';
+ }
+ if (! isset($dateParts[5])) {
+ $dateParts[5] = '';
+ }
+ if (intval(trim($dateParts[0])) > 0) {
+ $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' .
+ $dateParts[2] . ' ' . $dateParts[3];
+ return getGMTSeconds(strtotime($string), $dateParts[4]);
+ }
+ $string = $dateParts[0] . ' ' . $dateParts[1] . ' ' .
+ $dateParts[2] . ' ' . $dateParts[3] . ' ' . $dateParts[4];
+ if (isset($dateParts[5])) {
+ return getGMTSeconds(strtotime($string), $dateParts[5]);
+ } else {
+ return getGMTSeconds(strtotime($string), '');
+ }
+}