diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index be768ce4a1e..033432ccf2a 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -159,7 +159,7 @@ $var=!$var; print ''.$langs->trans("CurrentTimeZone").''; // Timezone server PHP $a=getCurrentTimeZoneString(); $a.=' '.getCurrentTimeZoneInt(); -$a.=' ('.(-dol_mktime(0,0,0,1,1,1970)>0?'+':'').(-dol_mktime(0,0,0,1,1,1970)).')'; +$a.=' ('.(getCurrentTimeZoneInt()>0?'+':'').(getCurrentTimeZoneInt()*3600).')'; print $form->textwithtooltip($a,$txt,2,1,img_info('')); print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php $var=!$var; @@ -203,4 +203,6 @@ print ''; print '
'; llxFooter(); + +$db->close(); ?> diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 95deaa800b2..9cc5a684008 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -86,7 +86,6 @@ class Conf $this->user=(object) array(); //! Charset for HTML output and for storing data in memory $this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1 - $this->global->MAIN_OLD_DATE=1; } diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 0cf224292b3..696934f4f85 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -76,14 +76,14 @@ function getCurrentTimeZoneString() /** * Return server timezone int. - * If $conf->global->MAIN_OLD_DATE is set, we use old behaviour: All convertion does not include daylight. + * If $conf->global->MAIN_NEW_DATE is set, we use new behaviour: All convertions take care of dayling saving time. * * @return string An offset in seconds (3600 for Europe/Paris on winter and 7200 for Europe/Paris on summer) */ function getCurrentTimeZoneInt() { global $conf; - if (class_exists('DateTime') && empty($conf->global->MAIN_OLD_DATE)) + if (class_exists('DateTime') && ! empty($conf->global->MAIN_NEW_DATE)) { // Method 1 (include daylight) $localtz = new DateTimeZone(date_default_timezone_get()); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7269cbdca94..85fa19196b0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1047,6 +1047,7 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$chec */ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) { + global $conf; //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; // Clean parameters @@ -1065,26 +1066,29 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) if ($second< 0 || $second > 60) return ''; } - $usealternatemethod=false; - if ($year <= 1970) $usealternatemethod=true; // <= 1970 - if ($year >= 2038) $usealternatemethod=true; // >= 2038 - - if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir + if (class_exists('DateTime') && ! empty($conf->global->MAIN_NEW_DATE)) { - /* - // On peut utiliser strtotime pour obtenir la traduction. - // strtotime is ok for range: Friday 13 December 1901 20:45:54 GMT to Tuesday 19 January 2038 03:14:07 GMT. - $montharray=array(1=>'january',2=>'february',3=>'march',4=>'april',5=>'may',6=>'june', - 7=>'july',8=>'august',9=>'september',10=>'october',11=>'november',12=>'december'); - $string=$day." ".$montharray[0+$month]." ".$year." ".$hour.":".$minute.":".$second." GMT"; - $date=strtotime($string); - print "- ".$string." ".$date." -"; - */ - $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm); + if (empty($gm)) $localtz = new DateTimeZone(date_default_timezone_get()); + else $localtz = new DateTimeZone('UTC'); + $dt = new DateTime(null,$localtz); + $dt->setDate($year,$month,$day); + $dt->setTime($hour,$minute,$second); + $date=$dt->getTimestamp(); } else { - $date=mktime($hour,$minute,$second,$month,$day,$year); + $usealternatemethod=false; + if ($year <= 1970) $usealternatemethod=true; // <= 1970 + if ($year >= 2038) $usealternatemethod=true; // >= 2038 + + if ($usealternatemethod || $gm) // Si time gm, seule adodb peut convertir + { + $date=adodb_mktime($hour,$minute,$second,$month,$day,$year,$isdst,$gm); + } + else + { + $date=mktime($hour,$minute,$second,$month,$day,$year); + } } return $date; } diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 54046659566..e93b6fb11c9 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -204,7 +204,7 @@ if (! defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset( * Include functions */ -if (! defined('ADODB_DATE_VERSION')) include_once(ADODB_PATH.'adodb-time.inc.php'); +if (! defined('ADODB_DATE_VERSION')) include_once(ADODB_PATH.'adodb-time.inc.php'); if (! file_exists(DOL_DOCUMENT_ROOT ."/core/lib/functions.lib.php")) { diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 31c0b410609..28c5c5936d1 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin @@ -75,8 +75,7 @@ if (! empty($dolibarr_main_document_root_alt)) } // Force db type (for test purpose) if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); - -// Multi-Company transverse mode +// Force Multi-Company transverse mode $conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; // Chargement des includes principaux de librairies communes diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php index 540c09fbc2a..0a98205f034 100755 --- a/test/phpunit/FunctionsTest.php +++ b/test/phpunit/FunctionsTest.php @@ -91,8 +91,11 @@ class FunctionsTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { global $conf,$user,$langs,$db; @@ -103,8 +106,11 @@ class FunctionsTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { print __METHOD__."\n"; @@ -222,6 +228,9 @@ class FunctionsTest extends PHPUnit_Framework_TestCase } /** + * testDolMkTime + * + * @return void */ public function testDolMkTime() { diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index c9e9d29f8f7..a11eaa9ad41 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -89,6 +89,9 @@ class PropalTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class PropalTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() {