From d1e484b312062c2a242608ccc0fff8f8b7a45f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Sat, 30 Mar 2002 08:24:04 +0000 Subject: [PATCH] Optimized a bit. --- libraries/zip.lib.php3 | 49 ++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/libraries/zip.lib.php3 b/libraries/zip.lib.php3 index a52f65b8e..88395139f 100755 --- a/libraries/zip.lib.php3 +++ b/libraries/zip.lib.php3 @@ -53,46 +53,29 @@ class zipfile /** - * Converts the date y/n/d and time h:m:s to a four byte DOS date and time - * format (date in high two bytes, time in low two bytes allowing magnitude - * comparison). + * Converts an Unix timestamp to a four byte DOS date and time format (date + * in high two bytes, time in low two bytes allowing magnitude comparison). * - * @param integer the current year - * @param integer the current month - * @param integer the current day - * @param integer the current hour - * @param integer the current minut - * @param integer the current second + * @param integer the current Unix timestamp * * @return integer the current date in a four byte DOS format * - * @access public - */ - function dosTime($year, $month, $day, $hour, $minute, $second) { - return ($year < 1980) - ? dosTime(1980, 1, 1, 0, 0, 0) - : (($year - 1980) << 25) | ($month << 21) | ($day << 16) | - ($hour << 11) | ($minute << 5) | ($second >> 1); - } // end of the 'dosTime()' method - - - /** - * Returns the Unix time $unixtime in DOS format, rounded up to the next - * two second boundary. - * - * @param integer the current timestamp - * - * @return integer the current date in a four byte DOS format - * - * @access public - * - * @see DOSTime() + * @access private */ function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); - return $this->dosTime($timearray['year'], $timearray['mon'], $timearray['mday'], - $timearray['hours'], $timearray['minutes'], $timearray['seconds']); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } // end if + + return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | + ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); } // end of the 'unix2DosTime()' method @@ -109,7 +92,7 @@ class zipfile { $name = str_replace('\\', '/', $name); - $dtime = dechex ($this->unix2DosTime($time)); + $dtime = dechex($this->unix2DosTime($time)); $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3]