First change to prepare usage of native PHP functions for date instead
of adodb-time library.
This commit is contained in:
parent
00de718e79
commit
866e8ac556
@ -155,24 +155,13 @@ print '<tr '.$bc[$var].'><td width="300"> => price(1234.56)</td><td>'.pric
|
||||
// Timezone
|
||||
$txt =$langs->trans("OSTZ").' (variable system TZ): '.($_ENV["TZ"]?$_ENV["TZ"]:$langs->trans("NotDefined")).'<br>'."\n";
|
||||
$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
|
||||
if (function_exists('date_default_timezone_get'))
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTimeZone").'</td><td>'; // Timezone server PHP
|
||||
$a=date_default_timezone_get();
|
||||
$a.=' '.getCurrentTimeZone();
|
||||
$a.=' ('.(-dol_mktime(0,0,0,1,1,1970)>0?'+':'').(-dol_mktime(0,0,0,1,1,1970)).')';
|
||||
print $form->textwithtooltip($a,$txt,2,1,img_info(''));
|
||||
print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
|
||||
}
|
||||
else
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("PHPServerOffsetWithGreenwich").'</td><td>';
|
||||
$a=(-dol_mktime(0,0,0,1,1,1970)>0?'+':'').(-dol_mktime(0,0,0,1,1,1970));
|
||||
print $form->textwithtooltip($a,$txt,2,1,img_info(''));
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("CurrentTimeZone").'</td><td>'; // 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)).')';
|
||||
print $form->textwithtooltip($a,$txt,2,1,img_info(''));
|
||||
print '</td></tr>'."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("CurrentHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzserver').'</td></tr>'."\n";
|
||||
$var=!$var;
|
||||
@ -188,18 +177,14 @@ $var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("CompanyHour").'</td><td>'.$langs->trans("FeatureNotYetAvailable").'</td></tr>'."\n";
|
||||
// Client
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("ClientTZ").'</td><td>'.($_SESSION['dol_tz']!=''?($_SESSION['dol_tz']>=0?'+':'').$_SESSION['dol_tz']:'').' ('.($_SESSION['dol_tz']>=0?'+':'').($_SESSION['dol_tz']*60*60).')</td></tr>'."\n";
|
||||
//$var=!$var;
|
||||
//print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("ClientOffsetWithGreenwich").'</td><td>'..'</td></tr>'."\n";
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("DaylingSavingTime").'</td><td>';
|
||||
if ($_SESSION['dol_dst']>0)
|
||||
{
|
||||
print ($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']).' ('.($_SESSION['dol_dst']>0?'+':'').($_SESSION['dol_dst']*60*60).')';
|
||||
}
|
||||
$tz=(int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
|
||||
print '<tr '.$bc[$var].'><td width="300">'.$langs->trans("ClientTZ").'</td><td>'.($tz?($tz>=0?'+':'').$tz:'').' ('.($tz>=0?'+':'').($tz*60*60).')';
|
||||
print ' '.$langs->trans("DaylingSavingTime").': ';
|
||||
if ($_SESSION['dol_dst']>0) print yn(1);
|
||||
else print yn(0);
|
||||
if (! empty($_SESSION['dol_dst_first'])) print ' ('.dol_print_date(dol_stringtotime($_SESSION['dol_dst_first']),'dayhour','gmt').' - '.dol_print_date(dol_stringtotime($_SESSION['dol_dst_second']),'dayhour','gmt').')';
|
||||
print '</td></tr>'."\n";
|
||||
print '</td></tr>'."\n";
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td width="300"> => '.$langs->trans("ClientHour").'</td><td>'.dol_print_date(dol_now(),'dayhour','tzuser').'</td></tr>'."\n";
|
||||
|
||||
|
||||
@ -709,7 +709,7 @@ if (count($listofextcals))
|
||||
$loop=true; $j=0;
|
||||
// daykey must be date that represent day box in calendar so must be a user time
|
||||
$daykey=dol_mktime(0,0,0,$mois,$jour,$annee);
|
||||
$daykeygmt=dol_mktime(0,0,0,$mois,$jour,$annee,true,0,false);
|
||||
$daykeygmt=dol_mktime(0,0,0,$mois,$jour,$annee,true,0);
|
||||
do
|
||||
//print 'x'.$datestart.'-'.$dateend;exit;
|
||||
{
|
||||
|
||||
@ -3123,7 +3123,6 @@ class Facture extends CommonObject
|
||||
$line->desc=$langs->trans("Description")." ".$xnbp;
|
||||
$line->qty=1;
|
||||
$line->subprice=100;
|
||||
//$line->price=100;
|
||||
$line->tva_tx=19.6;
|
||||
$line->localtax1_tx=0;
|
||||
$line->localtax2_tx=0;
|
||||
@ -3177,7 +3176,6 @@ class Facture extends CommonObject
|
||||
$line->desc=$langs->trans("Description")." (offered line)";
|
||||
$line->qty=1;
|
||||
$line->subprice=100;
|
||||
//$line->price=100;
|
||||
$line->tva_tx=19.6;
|
||||
$line->localtax1_tx=0;
|
||||
$line->localtax2_tx=0;
|
||||
|
||||
@ -59,14 +59,14 @@ class Conf
|
||||
public $entity=1;
|
||||
//! Used to store list of entities to use for each element
|
||||
public $entities = array();
|
||||
|
||||
public $modules = array(); // List of modules
|
||||
|
||||
public $modules = array(); // List of modules
|
||||
public $css_modules = array();
|
||||
public $tabs_modules = array();
|
||||
public $triggers_modules = array('/core/triggers');
|
||||
public $hooks_modules = array();
|
||||
public $login_method_modules = array();
|
||||
|
||||
|
||||
var $logbuffer = array();
|
||||
|
||||
|
||||
@ -86,6 +86,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +124,7 @@ class Conf
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
{
|
||||
$i = 0;
|
||||
$numr = $db->num_rows($resql);
|
||||
while ($i < $numr)
|
||||
@ -192,12 +193,12 @@ class Conf
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
// Object $mc
|
||||
if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled))
|
||||
{
|
||||
global $mc;
|
||||
|
||||
|
||||
$ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php');
|
||||
if ($ret)
|
||||
{
|
||||
|
||||
@ -63,18 +63,39 @@ function get_tz_array()
|
||||
|
||||
|
||||
/**
|
||||
* Return server timezone
|
||||
* Return server timezone string
|
||||
*
|
||||
* @return string TimeZone
|
||||
* @return string PHP server timezone string ('Europe/Paris')
|
||||
*/
|
||||
function getCurrentTimeZone()
|
||||
function getCurrentTimeZoneString()
|
||||
{
|
||||
// Method 1
|
||||
//$tzstring=date_default_timezone_get(); // Then convert into tz
|
||||
if (function_exists('date_default_timezone_get')) return date_default_timezone_get();
|
||||
else return '';
|
||||
}
|
||||
|
||||
// Method 2
|
||||
$tmp=dol_mktime(0,0,0,1,1,1970);
|
||||
$tz=($tmp<0?'+':'-').sprintf("%02d",abs($tmp/3600));
|
||||
|
||||
/**
|
||||
* Return server timezone int.
|
||||
* If $conf->global->MAIN_OLD_DATE is set, we use old behaviour: All convertion does not include daylight.
|
||||
*
|
||||
* @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))
|
||||
{
|
||||
// Method 1 (include daylight)
|
||||
$localtz = new DateTimeZone(date_default_timezone_get());
|
||||
$localdt = new DateTime("now", $localtz);
|
||||
$tmp=-1*$localtz->getOffset($localdt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Method 2 (does not include daylight)
|
||||
$tmp=dol_mktime(0,0,0,1,1,1970);
|
||||
}
|
||||
$tz=($tmp<0?'+':'-').abs($tmp/3600);
|
||||
return $tz;
|
||||
}
|
||||
|
||||
|
||||
@ -1042,11 +1042,10 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$chec
|
||||
* @param int $year Year
|
||||
* @param int $gm 1=Input informations are GMT values, otherwise local to server TZ
|
||||
* @param int $check 0=No check on parameters (Can use day 32, etc...)
|
||||
* @param int $isdst Dayling saving time
|
||||
* @return timestamp Date as a timestamp, '' if error
|
||||
* @see dol_print_date, dol_stringtotime, dol_getdate
|
||||
*/
|
||||
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1,$isdst=true)
|
||||
function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
|
||||
{
|
||||
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -27,6 +27,7 @@ global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
|
||||
|
||||
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
||||
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
||||
@ -219,5 +220,35 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testDolMkTime()
|
||||
{
|
||||
$result=dol_mktime(25,0,0,1,1,1970,1,1); // Error (25 hours)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
$result=dol_mktime(2,61,0,1,1,1970,1,1); // Error (61 minutes)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
$result=dol_mktime(2,1,61,1,1,1970,1,1); // Error (61 seconds)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
$result=dol_mktime(2,1,1,1,32,1970,1,1); // Error (day 32)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
$result=dol_mktime(2,1,1,13,1,1970,1,1); // Error (month 13)
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('',$result);
|
||||
|
||||
$result=dol_mktime(2,1,1,1,1,1970,1); // 1970-01-01 02:01:01 in GMT area -> 7261
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7261,$result);
|
||||
|
||||
$tz=getCurrentTimeZoneInt();
|
||||
$result=dol_mktime(2,0,0,1,1,1970,0); // 1970-01-01 02:00:00 in local area
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(7200-($tz*3600),$result);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user