diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index c357d0148d4..1dfe1eb03e7 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -157,10 +157,15 @@ $txt =$langs->trans("OSTZ").' (variable system TZ): '.($_ENV["TZ"]?$_ENV["TZ"]:$
$txt.=$langs->trans("PHPTZ").' (php.ini date.timezone): '.(ini_get("date.timezone")?ini_get("date.timezone"):$langs->trans("NotDefined")).''."\n"; // date.timezone must be in valued defined in http://fr3.php.net/manual/en/timezones.europe.php
$var=!$var;
print '
| '.$langs->trans("CurrentTimeZone").' | '; // Timezone server PHP
-$a=getServerTimeZoneString();
-$a.=' '.(getServerTimeZoneInt()>=0?'+':'').getServerTimeZoneInt();
-$a.=' ('.(getServerTimeZoneInt()>=0?'+':'').(getServerTimeZoneInt()*3600).')';
-print $form->textwithtooltip($a,$txt,2,1,img_info(''));
+$a=getServerTimeZoneInt('now');
+$b=getServerTimeZoneInt('winter');
+$c=getServerTimeZoneInt('summer');
+$daylight=round($b-$c);
+$val=($a>=0?'+':'').$a;
+$val.=' ('.($a>=0?'+':'').($a*3600).')';
+$val.=' '.getServerTimeZoneString().' '.($b>=0?'+':'').$b.' ('.($b>=0?'+':'').($b*3600).')';
+$val.=' '.$langs->trans("DaylingSavingTime").': '.yn($daylight);
+print $form->textwithtooltip($val,$txt,2,1,img_info(''));
print ' |
'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
$var=!$var;
print '| => '.$langs->trans("CurrentHour").' | '.dol_print_date(dol_now(),'dayhour','tzserver').' |
'."\n";
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index f535ab2ae29..5eebb0de99d 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -77,7 +77,7 @@ function getServerTimeZoneString()
* Return server timezone int.
* If $conf->global->MAIN_NEW_DATE is set, we use new behaviour: All convertions take care of dayling saving time.
*
- * @param string $refgmtdate Reference date for timezone (timezone differs on winter and summer)
+ * @param string $refgmtdate Reference period for timezone (timezone differs on winter and summer. May be 'now', 'winter' or 'summer')
* @return int An offset in hour (+1 for Europe/Paris on winter and +2 for Europe/Paris on summer)
*/
function getServerTimeZoneInt($refgmtdate='now')
@@ -92,8 +92,17 @@ function getServerTimeZoneInt($refgmtdate='now')
}
else
{
- // Method 2 (does not include daylight)
- $tmp=dol_mktime(0,0,0,1,1,1970);
+ // Method 2 (does not include daylight, not supported by adodb)
+ if ($refgmtdate == 'now')
+ {
+ $gmtnow=dol_now('gmt');
+ $monthnow=dol_print_date($gmtnow,'%m'); $daynow=dol_print_date($gmtnow,'%d');
+ if (dol_stringtotime($_SESSION['dol_dst_first']) <= $gmtnow && $gmtnow < dol_stringtotime($_SESSION['dol_dst_second'])) $daylight=1;
+ else $daylight=0;
+ $tmp=dol_mktime(0,0,0,$monthnow,$daynow,1970,false,0)-dol_mktime(0,0,0,$monthnow,$daynow,1970,true,0)-($daylight*3600);
+ }
+ else if ($refgmtdate == 'summer') $tmp=-1; // TODO
+ else $tmp=dol_mktime(0,0,0,1,1,1970);
}
$tz=($tmp<0?1:-1)*abs($tmp/3600);
return $tz;
@@ -781,4 +790,4 @@ function monthArray($outputlangs)
return $montharray;
}
-?>
\ No newline at end of file
+?>
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index a745e8e10a3..897fc62383b 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1007,7 +1007,7 @@ function dol_now($mode='gmt')
else if ($mode == 'tzserver') // Time for now with PHP server timezone added
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php');
- $tzsecond=getServerTimeZoneInt(); // Contains tz+dayling saving time
+ $tzsecond=getServerTimeZoneInt('now'); // Contains tz+dayling saving time
$ret=dol_now('gmt')+($tzsecond*3600);
}
/*else if ($mode == 'tzref') // Time for now with parent company timezone is added
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index a7e870d5da9..d028322987a 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -102,8 +102,13 @@ function dol_print_object_info($object)
$langs->load("other");
$langs->load("admin");
- $deltadateforuser=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
+ include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php');
+
+ $deltadateforserver=getServerTimeZoneInt('now');
+ $deltadateforclient=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
//$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
+ $deltadateforuser=round($deltadateforclient-$deltadateforserver);
+ //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
// Import key
if (isset($object->import_key))
@@ -129,8 +134,8 @@ function dol_print_object_info($object)
// Date
if (isset($object->date_creation))
{
- print $langs->trans("DateCreation")." : " . dol_print_date($object->date_creation,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateCreation")." : " . dol_print_date($object->date_creation,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_creation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
@@ -154,8 +159,8 @@ function dol_print_object_info($object)
// Date
if (isset($object->date_modification))
{
- print $langs->trans("DateLastModification")." : " . dol_print_date($object->date_modification,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateLastModification")." : " . dol_print_date($object->date_modification,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_modification+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
@@ -179,8 +184,8 @@ function dol_print_object_info($object)
// Date
if (isset($object->date_validation))
{
- print $langs->trans("DateValidation")." : " . dol_print_date($object->date_validation,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateValidation")." : " . dol_print_date($object->date_validation,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_validation+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
@@ -204,8 +209,8 @@ function dol_print_object_info($object)
// Date approve
if (isset($object->date_approve))
{
- print $langs->trans("DateApprove")." : " . dol_print_date($object->date_approve,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateApprove")." : " . dol_print_date($object->date_approve,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_approve+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
@@ -229,8 +234,8 @@ function dol_print_object_info($object)
// Date
if (isset($object->date_cloture))
{
- print $langs->trans("DateClosing")." : " . dol_print_date($object->date_cloture,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateClosing")." : " . dol_print_date($object->date_cloture,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_cloture+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
@@ -254,16 +259,16 @@ function dol_print_object_info($object)
// Date
if (isset($object->date_rappro))
{
- print $langs->trans("DateConciliating")." : " . dol_print_date($object->date_rappro,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateConciliating")." : " . dol_print_date($object->date_rappro,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_rappro+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
//Date send
if (isset($object->date_envoi))
{
- print $langs->trans("DateLastSend")." : " . dol_print_date($object->date_envoi,"dayhourtext");
- if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhourtext").' '.$langs->trans("ClientHour");
+ print $langs->trans("DateLastSend")." : " . dol_print_date($object->date_envoi,"dayhour");
+ if ($deltadateforuser) print ' '.$langs->trans("CurrentHour").' / '.dol_print_date($object->date_envoi+($deltadateforuser*3600),"dayhour").' '.$langs->trans("ClientHour");
print '
';
}
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 38b3fe7728e..46bdacba818 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -107,7 +107,7 @@ OSTZ=Time Zone OS server
PHPTZ=Time Zone PHP server
PHPServerOffsetWithGreenwich=PHP server offset width Greenwich (seconds)
ClientOffsetWithGreenwich=Client/Browser offset width Greenwich (seconds)
-DaylingSavingTime=Daylight saving time (user)
+DaylingSavingTime=Daylight saving time
CurrentHour=Hour PHP (server)
CompanyTZ= Time Zone company (main company)
CompanyHour= Hour company (main company)
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 6561c3b9749..860ed1816c1 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -108,7 +108,7 @@ OSTZ= Time Zone OS
PHPTZ= Time Zone config PHP
PHPServerOffsetWithGreenwich= Offset serveur PHP avec Greenwich (secondes)
ClientOffsetWithGreenwich= Offset client/navigateur avec Greenwich (secondes)
-DaylingSavingTime=Heure d'été (utilisateur)
+DaylingSavingTime=Heure d'été
CurrentHour= Heure PHP (serveur)
CompanyTZ= Time Zone société (maison mère)
CompanyHour= Heure société (maison mère)
diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php
index 2a81b2e6d4e..2952389ba76 100755
--- a/test/phpunit/FunctionsTest.php
+++ b/test/phpunit/FunctionsTest.php
@@ -322,9 +322,9 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
print __METHOD__." result=".$result."\n";
$this->assertEquals(7261,$result);
- $result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 in local area Europe/Paris -> 3600 GMT
+ $result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 = 7200 in local area Europe/Paris = 3600 GMT
print __METHOD__." result=".$result."\n";
- $tz=getServerTimeZoneInt('1970-01-01 02:00:00'); // +1 in Europe/Paris at this time (this time is winter)
+ $tz=getServerTimeZoneInt('winter'); // +1 in Europe/Paris at this time (this time is winter)
$this->assertEquals(7200-($tz*3600),$result); // Should be 7200 if we are at greenwich winter
}
@@ -337,8 +337,8 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
{
$now=dol_now('gmt');
$nowtzserver=dol_now('tzserver');
- print __METHOD__."getServerTimeZoneInt=".(getServerTimeZoneInt()*3600)."\n";
- $this->assertEquals(getServerTimeZoneInt()*3600,($nowtzserver-$now));
+ print __METHOD__."getServerTimeZoneInt=".(getServerTimeZoneInt('now')*3600)."\n";
+ $this->assertEquals(getServerTimeZoneInt('now')*3600,($nowtzserver-$now));
}
/**
@@ -395,4 +395,4 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$this->assertEquals($arraytotest,$decoded);
}
}
-?>
\ No newline at end of file
+?>