[PHP] Dates problem

2005-04-27 Thread Mario de Frutos Dieguez
Hi!
I have a problem with dates. I have a function that sum a duration in 
laboral days to an initial date. The problem come when the function 
reaches the last sunday of October, the data remains in the last sunday 
of October and make an infinite loop. The functions works fine i have 
test in all the cases and only fails in the last sunday of October.

Can anyone help me?
Thanks in advance.
PD: Jochem home english is bad english :P
--
Mario de Frutos Dieguez
División de Ingeniería del Software
y Comunicaciones  

CARTIF -Parque Tecnológico Boecillo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Dates problem

2005-04-27 Thread Petar Nedyalkov
On Wednesday 27 April 2005 09:17, Mario de Frutos Dieguez wrote:
 Hi!

 I have a problem with dates. I have a function that sum a duration in
 laboral days to an initial date. The problem come when the function
 reaches the last sunday of October, the data remains in the last sunday
 of October and make an infinite loop. The functions works fine i have
 test in all the cases and only fails in the last sunday of October.

So, let's see the function.


 Can anyone help me?

 Thanks in advance.

 PD: Jochem home english is bad english :P

 --
 Mario de Frutos Dieguez

 División de Ingeniería del Software
 y Comunicaciones

 CARTIF -Parque Tecnológico Boecillo

-- 

Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)

PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436


pgpcnojEYuGrX.pgp
Description: PGP signature


Re: [PHP] Dates problem

2005-04-27 Thread Mario de Frutos Dieguez
Petar Nedyalkov escribió:
On Wednesday 27 April 2005 09:17, Mario de Frutos Dieguez wrote:
 

Hi!
I have a problem with dates. I have a function that sum a duration in
laboral days to an initial date. The problem come when the function
reaches the last sunday of October, the data remains in the last sunday
of October and make an infinite loop. The functions works fine i have
test in all the cases and only fails in the last sunday of October.
   

So, let's see the function.
 

Can anyone help me?
Thanks in advance.
PD: Jochem home english is bad english :P
--
Mario de Frutos Dieguez
División de Ingeniería del Software
y Comunicaciones
CARTIF -Parque Tecnológico Boecillo
   

 

function aCalculaFechas($oSqlBDGestion,$fecFechaIniProyecto,$iDuracion)
   {
   $iCont=0;
  
   //Descomponemos los argumentos y pasamos las fechas a 
formato Y/m/d
   $aFecIniTemp=split(/,$fecFechaIniProyecto);
   
$fecFechaInicio=date(Y/m/d,mktime(0,0,0,$aFecIniTemp[1],$aFecIniTemp[0],$aFecIniTemp[2]));
  
   if ($iDuracion0)
   {
   //Generamos una fecha temporal sobre la que haremos los 
cálculos
   $fecFechaFinTemp=$fecFechaInicio;
  
   //Sumamos uno a la fecha para iniciar la cuenta de la 
duración un día despues de la fecha de inicio
   $fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,1);
  
   //Ejecutamos un bucle que irá calculando la duración 
total (incluyendo sabados y domingos) a partir de la duración
   //laboral
   while ($iCont($iDuracion))
   {
   //Obtenemos el día de la semana del día que estamos 
mirando  
   $aFecTempCalculo=split('/',$fecFechaFinTemp);
   
$iDiaSemanaTemp=date(w,mktime(0,0,0,$aFecTempCalculo[1],$aFecTempCalculo[2],$aFecTempCalculo[0]));
   //Si el día es distinto de domingo o sabado 
aumentamos el contador de duración laboral
   if ($iDiaSemanaTemp!=6  $iDiaSemanaTemp!=0)
   {
   $iCont++;
   }
   //Se añade uno más a la fecha
   $fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,1);
   //Siempre se añade uno al número de días totales.
   $iNumDiasTotales++;
   //echo $iNumDiasTotales.'br';
   }
  
   //Sumamos al a fecha temporal el número de dias totales 
(solo incluidos sabados y domingos)
   
$fecFechaFinTemp=$this-SumarFechas($fecFechaInicio,$iNumDiasTotales);
  
   //Hacemos un bucle obteniendo los días festivos usando 
la fecha final temporal y hasta que no se obtengan dias
   //festivos sigue sumandolos.
   do
   {
   //echo SELECT * FROM festivos WHERE dia_festivo 
BETWEEN '.$fecFechaInicio.' AND '.$fecFechaFinTemp.';
   //Obtenemos los dias festivos entre el rango de fechas
   
$iObtenDiasFest=$oSqlBDGestion-iEjecutarConsulta(SELECT * FROM 
festivos WHERE dia_festivo BETWEEN '.$fecFechaInicio.' AND 
'.$fecFechaFinTemp.');
  
   
$iNumDiasFestivos=$oSqlBDGestion-iNumeroFilasResultadoConsulta($iObtenDiasFest);
  
   $fecFechaInicio=$this-SumarFechas($fecFechaFinTemp,1);
   
$fecFechaFinTemp=$this-SumarFechas($fecFechaFinTemp,$iNumDiasFestivos);
  
   }while ($iNumDiasFestivos0);
  
   $aFecTempCalculo=split('/',$fecFechaFinTemp);
   
$iDiaSemanaTemp=date(w,mktime(0,0,0,$aFecTempCalculo[1],$aFecTempCalculo[2],$aFecTempCalculo[0]));
   if ($iDiaSemanaTemp==6)
   $fecFechaFin=$this-SumarFechas($fecFechaFinTemp,3);
   else if ($iDiaSemanaTemp==0)
   $fecFechaFin=$this-SumarFechas($fecFechaFinTemp,2);
   else
   $fecFechaFin=$fecFechaFinTemp;
   $aFecFin=split(/,$fecFechaFin);
   
$fecFechaFin=date(d/m/Y,mktime(0,0,0,$aFecFin[1],$aFecFin[2],$aFecFin[0]));
   }
   else
   $fecFechaFin=$fecFechaIniProyecto;

  
   return $fecFechaFin;
   }

--
Mario de Frutos Dieguez
División de Ingeniería del Software
y Comunicaciones  

CARTIF -Parque Tecnológico Boecillo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] dates problem

2001-09-08 Thread Nikola Veber

I'm having a prowith determing a time interval. I need to find out how many 
seconds, minutes, days have passed since a cpecific date (1.1.1980.), but when I 
pass that dade to a time stamp , I get 1983.315529200. How am I suposed to 
handle the year (1983.) o there is smething else ? I think the only way to do this is
to make the time stamp for the interval between now and the specific date.

thanx
Nikola Veber


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]