From eb86abff94406ec08766462f57ba2209341d2876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 15 Mar 2014 05:47:17 +0100 Subject: [PATCH] Database: factorized jdate() --- htdocs/core/db/DoliDB.class.php | 19 +++++++++++++++++-- htdocs/core/db/mssql.class.php | 17 ----------------- htdocs/core/db/mysql.class.php | 17 ----------------- htdocs/core/db/mysqli.class.php | 17 ----------------- htdocs/core/db/pgsql.class.php | 17 ----------------- htdocs/core/db/sqlite.class.php | 18 ------------------ 6 files changed, 17 insertions(+), 88 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 6f5a75b35abc8..7d6afd224575c 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -64,8 +64,6 @@ abstract class DoliDB implements Database public $ok; public $error; - - /** * Define sort criteria of request * @@ -94,5 +92,22 @@ function order($sortfield=0,$sortorder=0) return ''; } } + + /** + * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) + * 19700101020000 -> 3600 with TZ+1 and gmt=0 + * 19700101020000 -> 7200 whaterver is TZ if gmt=1 + * + * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) + * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ + * @return date Date TMS + */ + function jdate($string, $gm=false) + { + $string=preg_replace('/([^0-9])/i','',$string); + $tmp=$string.'000000'; + $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); + return $date; + } } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 0e1b1a2ca0cb7..ae8e6ea5ce6e7 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -553,23 +553,6 @@ function idate($param) return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 46b16113a26b4..bd6c2794b174b 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -531,23 +531,6 @@ function idate($param) return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index ece1ff86532ac..f530656cc7f52 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -541,23 +541,6 @@ function idate($param) return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index aa31f5616c8cc..7b2961e623c55 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -752,23 +752,6 @@ function idate($param) return dol_print_date($param,"%Y-%m-%d %H:%M:%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - /** * Format a SQL IF * diff --git a/htdocs/core/db/sqlite.class.php b/htdocs/core/db/sqlite.class.php index 36f583011e4bd..67dc9593042b0 100644 --- a/htdocs/core/db/sqlite.class.php +++ b/htdocs/core/db/sqlite.class.php @@ -674,24 +674,6 @@ function idate($param) return dol_print_date($param,"%Y%m%d%H%M%S"); } - /** - * Convert (by PHP) a PHP server TZ string date into a Timestamps date (GMT if gm=true) - * 19700101020000 -> 3600 with TZ+1 and gmt=0 - * 19700101020000 -> 7200 whaterver is TZ if gmt=1 - * - * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) - * @param int $gm 1=Input informations are GMT values, otherwise local to server TZ - * @return date Date TMS - */ - function jdate($string, $gm=false) - { - $string=preg_replace('/([^0-9])/i','',$string); - $tmp=$string.'000000'; - $date=dol_mktime(substr($tmp,8,2),substr($tmp,10,2),substr($tmp,12,2),substr($tmp,4,2),substr($tmp,6,2),substr($tmp,0,4),$gm); - return $date; - } - - /** * Format a SQL IF *