PM-1115 "16306: Date Field not showing next date after 1969" SOLVED

Issue:
    16306: Date Field not showing next date after 1969
Cause:
    Esto se debe a la funcion "mktime" de PHP para Windows el cual tiene una limitante
    en el rango de fechas (rango valido entre 1901 y 2038). Para mas detalles
    visite el sgte link ----> http://php.net/manual/en/function.mktime.php
Solution:
    Se ha mejorado el metodo "calculateBeforeFormat" de la clase "XmlForm_Field_Date" el
    cual verifica el total de añde la fecha que se obtiene con "mktime"; esto solo
    para servidores Windows
This commit is contained in:
Victor Saisa Lopez
2014-12-12 17:33:13 -04:00
parent d048b55613
commit 9531d78fe1

View File

@@ -4493,17 +4493,50 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
{
$part1 = $sign * substr( $date, 0, strlen( $date ) - 1 );
$part2 = substr( $date, strlen( $date ) - 1 );
$year = (int)(date("Y"));
$month = (int)(date("m"));
$day = (int)(date("d"));
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
$checkYear = false;
switch ($part2) {
case 'd':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + $part1, date( 'Y' ) ) );
case "y":
$year = $year + $part1;
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
$checkYear = true;
break;
case 'm':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ) + $part1, date( 'd' ), date( 'Y' ) ) );
case "m":
$month = $month + $part1;
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
if ($month > 12) {
$year = $year + (int)($month / 12);
$checkYear = true;
}
break;
case 'y':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + $part1 ) );
case "d":
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day + $part1, $year));
$dayAux = ($month * 31) - (31 - $day) + $part1;
if ($dayAux > 365) {
$year = $year + (int)($dayAux / 365);
$checkYear = true;
}
break;
}
if (!$osIsLinux && $checkYear && !preg_match("/^$year\-\d{2}\-\d{2}$/", $res)) {
$res = preg_replace("/^\d{4}(\-\d{2}\-\d{2})$/", "$year$1", $res);
}
return $res;
}