aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-02 18:57:21 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-03 09:54:44 -0400
commit1bff18eba5999ee7d7fefae0a8519411db25119a (patch)
tree24bb42761cf4f326834f8dd0044ac1027895ad33
parentac1ddfe5a3b3c97cfab1ae375f201f3f2d241e19 (diff)
downloadzipstream-php-1bff18eba5999ee7d7fefae0a8519411db25119a.tar.bz2
zipstream-php-1bff18eba5999ee7d7fefae0a8519411db25119a.zip
clean up date/time parsing
-rw-r--r--src/ZipStream.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ZipStream.php b/src/ZipStream.php
index e205226..9412438 100644
--- a/src/ZipStream.php
+++ b/src/ZipStream.php
@@ -456,8 +456,17 @@ final class DateTime {
# remove extra years from 1980
$d['year'] -= 1980;
- $this->dos_date = ($d['year'] << 9) | ($d['mon'] << 5) | ($d['mday']);
- $this->dos_time = ($d['hours'] << 11) | ($d['minutes'] << 5) | ($d['seconds'] >> 1);
+ $this->dos_date = (
+ (($d['year'] & 0x7F) << 9) |
+ (($d['mon'] & 0xF) << 5) |
+ ($d['mday'] & 0x1F)
+ );
+
+ $this->dos_time = (
+ (($d['hours'] & 0x3F) << 11) |
+ (($d['minutes'] & 0x3F) << 5) |
+ (($d['seconds'] & 0x3F) >> 1)
+ );
}
};