From a6b2eab43933e00e6deae3bec7902d2c1ff850f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Sep 2012 22:09:54 +0200 Subject: [PATCH] Revert bad fix. Unit tests are back ok (when tag is @6 or @=, yearoffset is not zero but must not be applied when replacing yyyy). Compatibility with 3.2 is also restored. --- htdocs/core/lib/functions2.lib.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 85dec26ca95..87d6a91d92f 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -810,20 +810,18 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $numFinal = $mask; // We replace special codes except refclient - // FIXME: $yearoffset is 0 by default, this code is useless - //if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year - //{ + if (! empty($yearoffsettype) && ! is_numeric($yearoffsettype) && $yearoffsettype != '=') // yearoffsettype is - or +, so we don't want current year + { $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date)+$yearoffset, $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y",$date)+$yearoffset, $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),2,1)+$yearoffset, $numFinal); - //} - /* + } else // we want yyyy to be current year { $numFinal = preg_replace('/\{yyyy\}/i',date("Y",$date), $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y",$date), $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y",$date),2,1), $numFinal); - }*/ + } $numFinal = preg_replace('/\{mm\}/i', date("m",$date), $numFinal); $numFinal = preg_replace('/\{dd\}/i', date("d",$date), $numFinal);