Skip to content
Extraits de code Groupes Projets
Valider a168bb47 rédigé par cerdic's avatar cerdic
Parcourir les fichiers

simplifier les fonctions de date pour sqlite en reposant dans tous les cas sur...

simplifier les fonctions de date pour sqlite en reposant dans tous les cas sur _sqlite_func_unix_timestamp et date(),
plutot que de recoder une regexp differente, possiblement bugguee, dans chaque fonction.

(plus coquille de nom de variable et indentation)
parent ee1d6514
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -113,14 +113,7 @@ function _sqlite_func_concat ($a, $b) { ...@@ -113,14 +113,7 @@ function _sqlite_func_concat ($a, $b) {
// http://doc.spip.org/@_sqlite_func_dayofmonth // http://doc.spip.org/@_sqlite_func_dayofmonth
function _sqlite_func_dayofmonth ($d) { function _sqlite_func_dayofmonth ($d) {
if (!$d){ return date("d",_sqlite_func_unix_timestamp($d));
$result = date("j");
} else {
preg_match(";^([0-9]{4})-([0-9]+)-([0-9]+) .*$;", $d, $f);
$result = $f[3];
}
#spip_log("Passage avec DAYOFMONTH : $d, $result",'debug');
return $result;
} }
...@@ -151,10 +144,10 @@ function _sqlite_func_if ($bool, $oui, $non) { ...@@ -151,10 +144,10 @@ function _sqlite_func_if ($bool, $oui, $non) {
*/ */
// http://doc.spip.org/@_sqlite_func_insert // http://doc.spip.org/@_sqlite_func_insert
function _sqlite_func_insert ($s, $index, $longueur, $chaine) { function _sqlite_func_insert ($s, $index, $longueur, $chaine) {
return return
substr($s,0, $index) substr($s,0, $index)
. $chaine . $chaine
. substr(substr($s, $index), $longueur); . substr(substr($s, $index), $longueur);
} }
...@@ -185,7 +178,7 @@ function _sqlite_func_left ($s, $lenght) { ...@@ -185,7 +178,7 @@ function _sqlite_func_left ($s, $lenght) {
// http://doc.spip.org/@_sqlite_func_now // http://doc.spip.org/@_sqlite_func_now
function _sqlite_func_now(){ function _sqlite_func_now(){
$result = date("Y-m-d H:i:s", strtotime("now")); $result = date("Y-m-d H:i:s");
#spip_log("Passage avec NOW : $result",'debug'); #spip_log("Passage avec NOW : $result",'debug');
return $result; return $result;
} }
...@@ -193,10 +186,7 @@ function _sqlite_func_now(){ ...@@ -193,10 +186,7 @@ function _sqlite_func_now(){
// http://doc.spip.org/@_sqlite_func_month // http://doc.spip.org/@_sqlite_func_month
function _sqlite_func_month ($d) { function _sqlite_func_month ($d) {
#spip_log("Passage avec MONTH : $d",'debug'); return date("m",_sqlite_func_unix_timestamp($d));
if (!$d) return date("n");
preg_match(";^([0-9]{4})-([0-9]+).*$;", $d, $f);
return $f[2];
} }
...@@ -211,13 +201,13 @@ function _sqlite_func_preg_replace($quoi, $cherche, $remplace) { ...@@ -211,13 +201,13 @@ function _sqlite_func_preg_replace($quoi, $cherche, $remplace) {
// http://doc.spip.org/@_sqlite_func_rand // http://doc.spip.org/@_sqlite_func_rand
function _sqlite_func_rand() { function _sqlite_func_rand() {
return rand(); return rand();
} }
// http://doc.spip.org/@_sqlite_func_right // http://doc.spip.org/@_sqlite_func_right
function _sqlite_func_right ($s, $lenght) { function _sqlite_func_right ($s, $length) {
return substr($s,0 - $lenght); return substr($s,0 - $length);
} }
...@@ -255,14 +245,7 @@ function _sqlite_func_unix_timestamp($d) { ...@@ -255,14 +245,7 @@ function _sqlite_func_unix_timestamp($d) {
// http://doc.spip.org/@_sqlite_func_year // http://doc.spip.org/@_sqlite_func_year
function _sqlite_func_year ($d) { function _sqlite_func_year ($d) {
if (!$d){ return date("Y",_sqlite_func_unix_timestamp($d));
$result = date("Y");
} else {
preg_match(";^([0-9]{4}).*$;", $d, $f);
$result = $f[1];
}
spip_log("Passage avec YEAR : $d, $result",'debug');
return $result;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter