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