From 593e5996d41c8cd8fbc5fbdb38d00dcac4c9d47d Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 28 Jun 2020 10:14:24 +0200 Subject: [PATCH] baculum: Fix date formatter to work with PHP 7.4 Stop using defaultToCurrentTime variable - Baculum doesn't use it. --- ...-date-formatter-to-work-with-php-7-4.patch | 55 +++++++++++++++++++ .../framework/Util/TSimpleDateFormatter.php | 35 ++++-------- 2 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 gui/baculum/debian/patches/fix-date-formatter-to-work-with-php-7-4.patch diff --git a/gui/baculum/debian/patches/fix-date-formatter-to-work-with-php-7-4.patch b/gui/baculum/debian/patches/fix-date-formatter-to-work-with-php-7-4.patch new file mode 100644 index 000000000..021da9c01 --- /dev/null +++ b/gui/baculum/debian/patches/fix-date-formatter-to-work-with-php-7-4.patch @@ -0,0 +1,55 @@ +diff --git a/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php b/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php +index f85879c9e0..00fc12770b 100644 +--- a/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php ++++ b/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php +@@ -244,16 +244,9 @@ class TSimpleDateFormatter + $x = null; + $y = null; + +- +- if ($defaultToCurrentTime) { +- $year = "{$date['year']}"; +- $month = $date['mon']; +- $day = $date['mday']; +- } else { +- $year = null; +- $month = null; +- $day = null; +- } ++ $year = null; ++ $month = null; ++ $day = null; + + while ($i_format < $pattern_length) { + $c = $this->charAt($pattern, $i_format); +@@ -332,21 +325,17 @@ class TSimpleDateFormatter + if ($i_val != $this->length($value)) { + return null; + } +- //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); +- if (!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) { +- return null; +- } else { +- if (empty($year)) { +- $year = date('Y'); +- } +- $day = (int) $day <= 0 ? 1 : (int) $day; +- $month = (int) $month <= 0 ? 1 : (int) $month; + +- $s = new \DateTime; +- $s->setDate($year, $month, $day); +- $s->setTime(0, 0, 0); +- return $s->getTimeStamp(); ++ if (empty($year)) { ++ $year = date('Y'); + } ++ $day = (int) $day <= 0 ? 1 : (int) $day; ++ $month = (int) $month <= 0 ? 1 : (int) $month; ++ ++ $s = new \DateTime; ++ $s->setDate($year, $month, $day); ++ $s->setTime(0, 0, 0); ++ return $s->getTimeStamp(); + } + + /** diff --git a/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php b/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php index f85879c9e..00fc12770 100644 --- a/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php +++ b/gui/baculum/framework/pradosoft/prado/framework/Util/TSimpleDateFormatter.php @@ -244,16 +244,9 @@ class TSimpleDateFormatter $x = null; $y = null; - - if ($defaultToCurrentTime) { - $year = "{$date['year']}"; - $month = $date['mon']; - $day = $date['mday']; - } else { - $year = null; - $month = null; - $day = null; - } + $year = null; + $month = null; + $day = null; while ($i_format < $pattern_length) { $c = $this->charAt($pattern, $i_format); @@ -332,21 +325,17 @@ class TSimpleDateFormatter if ($i_val != $this->length($value)) { return null; } - //throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value); - if (!$defaultToCurrentTime && ($month === null || $day === null || $year === null)) { - return null; - } else { - if (empty($year)) { - $year = date('Y'); - } - $day = (int) $day <= 0 ? 1 : (int) $day; - $month = (int) $month <= 0 ? 1 : (int) $month; - $s = new \DateTime; - $s->setDate($year, $month, $day); - $s->setTime(0, 0, 0); - return $s->getTimeStamp(); + if (empty($year)) { + $year = date('Y'); } + $day = (int) $day <= 0 ? 1 : (int) $day; + $month = (int) $month <= 0 ? 1 : (int) $month; + + $s = new \DateTime; + $s->setDate($year, $month, $day); + $s->setTime(0, 0, 0); + return $s->getTimeStamp(); } /** -- 2.47.3