hello oversight
This commit is contained in:
parent
6761867603
commit
312ffc8fac
1 changed files with 19 additions and 19 deletions
|
@ -288,21 +288,21 @@ class FWIF {
|
|||
if($subYear)
|
||||
$year = ~$year;
|
||||
|
||||
$ymdfh = $subYear ? self::DATETIME_YEAR_SIGN : 0;
|
||||
$ymdfh |= ($year & self::DATETIME_YEAR_MASK) << self::DATETIME_YEAR_SHIFT;
|
||||
$ymdfh |= ($month & self::DATETIME_MONTH_MASK) << self::DATETIME_MONTH_SHIFT;
|
||||
$ymdfh |= ($day & self::DATETIME_DAY_MASK) << self::DATETIME_DAY_SHIFT;
|
||||
$ymdfh |= ($hours & self::DATETIME_HOUR_MASK);
|
||||
$ymdh = $subYear ? self::DATETIME_YEAR_SIGN : 0;
|
||||
$ymdh |= ($year & self::DATETIME_YEAR_MASK) << self::DATETIME_YEAR_SHIFT;
|
||||
$ymdh |= ($month & self::DATETIME_MONTH_MASK) << self::DATETIME_MONTH_SHIFT;
|
||||
$ymdh |= ($day & self::DATETIME_DAY_MASK) << self::DATETIME_DAY_SHIFT;
|
||||
$ymdh |= ($hours & self::DATETIME_HOUR_MASK);
|
||||
|
||||
$mins = (int)$dt->format('i');
|
||||
$secs = (int)$dt->format('s');
|
||||
$millis = ($flags & self::DISCARD_MILLISECONDS) ? 0 : (int)$dt->format('v');
|
||||
|
||||
if($mins > 0 || $secs > 0 || $millis > 0) {
|
||||
$ymdfh |= self::DATETIME_FLAG_TIME;
|
||||
$msw = 0;
|
||||
$msw |= ($mins & self::DATETIME_MINS_MASK) << self::DATETIME_MINS_SHIFT;
|
||||
$msw |= ($secs & self::DATETIME_SECS_MASK) << self::DATETIME_SECS_SHIFT;
|
||||
$ymdh |= self::DATETIME_FLAG_TIME;
|
||||
$msw = 0;
|
||||
$msw |= ($mins & self::DATETIME_MINS_MASK) << self::DATETIME_MINS_SHIFT;
|
||||
$msw |= ($secs & self::DATETIME_SECS_MASK) << self::DATETIME_SECS_SHIFT;
|
||||
|
||||
if($millis > 0) {
|
||||
$msw |= self::DATETIME_FLAG_MILLI;
|
||||
|
@ -311,8 +311,8 @@ class FWIF {
|
|||
}
|
||||
}
|
||||
|
||||
$packed = pack('N', $ymdfh);
|
||||
if($ymdfh & self::DATETIME_FLAG_TIME) {
|
||||
$packed = pack('N', $ymdh);
|
||||
if($ymdh & self::DATETIME_FLAG_TIME) {
|
||||
$packed .= pack('n', $msw);
|
||||
if($msw & self::DATETIME_FLAG_MILLI)
|
||||
$packed .= chr($w);
|
||||
|
@ -321,18 +321,18 @@ class FWIF {
|
|||
return $packed;
|
||||
}
|
||||
private static function decodeDateTime($data, int $flags): DateTimeInterface {
|
||||
$ymdfh = unpack('N', fread($data, 4))[1];
|
||||
$hasMsw = $ymdfh & self::DATETIME_FLAG_TIME;
|
||||
$ymdh = unpack('N', fread($data, 4))[1];
|
||||
$hasMsw = $ymdh & self::DATETIME_FLAG_TIME;
|
||||
$msw = $hasMsw ? unpack('n', fread($data, 2))[1] : 0;
|
||||
$hasW = $hasMsw && ($msw & self::DATETIME_FLAG_MILLI);
|
||||
$w = $hasW ? ord(fgetc($data)) : 0;
|
||||
|
||||
$year = ($ymdfh >> self::DATETIME_YEAR_SHIFT) & self::DATETIME_YEAR_MASK;
|
||||
$month = ($ymdfh >> self::DATETIME_MONTH_SHIFT) & self::DATETIME_MONTH_MASK;
|
||||
$day = ($ymdfh >> self::DATETIME_DAY_SHIFT) & self::DATETIME_DAY_MASK;
|
||||
$hour = $ymdfh & self::DATETIME_HOUR_MASK;
|
||||
$year = ($ymdh >> self::DATETIME_YEAR_SHIFT) & self::DATETIME_YEAR_MASK;
|
||||
$month = ($ymdh >> self::DATETIME_MONTH_SHIFT) & self::DATETIME_MONTH_MASK;
|
||||
$day = ($ymdh >> self::DATETIME_DAY_SHIFT) & self::DATETIME_DAY_MASK;
|
||||
$hour = $ymdh & self::DATETIME_HOUR_MASK;
|
||||
|
||||
if($ymdfh & self::DATETIME_YEAR_SIGN)
|
||||
if($ymdh & self::DATETIME_YEAR_SIGN)
|
||||
$year = ~$year;
|
||||
$dt = sprintf('%04d-%02d-%02dT%02d:', $year, $month, $day, $hour);
|
||||
|
||||
|
@ -340,7 +340,7 @@ class FWIF {
|
|||
$mins = ($msw >> self::DATETIME_MINS_SHIFT) & self::DATETIME_MINS_MASK;
|
||||
$secs = ($msw >> self::DATETIME_SECS_SHIFT) & self::DATETIME_SECS_MASK;
|
||||
$dt .= sprintf('%02d:%02d', $mins, $secs);
|
||||
if($hasV) {
|
||||
if($hasW) {
|
||||
$millis = ($msw << self::DATETIME_MILLI_HI_SHIFT) & self::DATETIME_MILLI_HI_MASK;
|
||||
$millis |= $w;
|
||||
$dt .= sprintf('.%03d', $millis);
|
||||
|
|
Reference in a new issue