From 1bff18eba5999ee7d7fefae0a8519411db25119a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 2 Sep 2018 18:57:21 -0400 Subject: clean up date/time parsing --- src/ZipStream.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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) + ); } }; -- cgit v1.2.3