Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / var / www / html / sman1baleendah_sch_id / functions / | server ip : 104.21.89.46 your ip : 172.70.179.174 H O M E |
Filename | /var/www/html/sman1baleendah_sch_id/functions/exceldate.php |
Size | 2.25 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 11-Jun-2025 21:32 |
Last modified | 11-Jun-2025 21:32 |
Last accessed | 16-Jun-2025 11:11 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
define ('ABC_BAD_DATE', -1);
/**
* @package ExcelDateUtil
*/
class ExcelDateUtil{
/*
* return 1900 Date as integer TIMESTAMP.
* for UNIX date must be
*
* @param int $date
* @return
*/
function xls2tstamp($date) {
$date = ($date > 25568) ? $date : 25569;
/*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/
$ofs = (70 * 365 + 17+2) * 86400;
return ($date * 86400) - $ofs;
}
/**
* Return date as array("day"=>,"month"=>,"year"=>)
*
* @param int
* @return array
*/
function getDateArray($xls_date){
$ret = array();
// leap year bug
if ($xls_date == 60) {
$ret['day'] = 29;
$ret['month'] = 2;
$ret['year'] = 1900;
return $ret;
} else if ($xls_date < 60) {
// 29-02-1900 bug
$xls_date++;
}
// Modified Julian to DMY calculation with an addition of 2415019
$l = $xls_date + 68569 + 2415019;
$n = (int)(( 4 * $l ) / 146097);
$l = $l - (int)(( 146097 * $n + 3 ) / 4);
$i = (int)(( 4000 * ( $l + 1 ) ) / 1461001);
$l = $l - (int)(( 1461 * $i ) / 4) + 31;
$j = (int)(( 80 * $l ) / 2447);
$ret['day'] = $l - (int)(( 2447 * $j ) / 80);
$l = (int)($j / 11);
$ret['month'] = $j + 2 - ( 12 * $l );
$ret['year'] = 100 * ( $n - 49 ) + $i + $l;
return $ret;
}
/**
* Check date format
*
* Internal Date Formats as described on page 427 in
* Microsoft Excel Dev's Kit...
* @deprecated
* @param int
* @return bool
*/
function isInternalDateFormat($format)
{
$retval =false;
switch ($format) {
// Internal Date Formats as described on page 427 in
// Microsoft Excel Dev's Kit...
case 0x0e:
case 0x0f:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x2d:
case 0x2e:
case 0x2f:
// Additional internal date formats found by inspection
// Using Excel v.X 10.1.0 (Mac)
case 0xa4:
case 0xa5:
case 0xa6:
case 0xa7:
case 0xa8:
case 0xa9:
case 0xaa:
case 0xab:
case 0xac:
case 0xad:
$retval = true;
break;
default:
$retval = false;
break;
}
return $retval;
}
}
?>
define ('ABC_BAD_DATE', -1);
/**
* @package ExcelDateUtil
*/
class ExcelDateUtil{
/*
* return 1900 Date as integer TIMESTAMP.
* for UNIX date must be
*
* @param int $date
* @return
*/
function xls2tstamp($date) {
$date = ($date > 25568) ? $date : 25569;
/*There was a bug if Converting date before 1-1-1970 (tstamp 0)*/
$ofs = (70 * 365 + 17+2) * 86400;
return ($date * 86400) - $ofs;
}
/**
* Return date as array("day"=>,"month"=>,"year"=>)
*
* @param int
* @return array
*/
function getDateArray($xls_date){
$ret = array();
// leap year bug
if ($xls_date == 60) {
$ret['day'] = 29;
$ret['month'] = 2;
$ret['year'] = 1900;
return $ret;
} else if ($xls_date < 60) {
// 29-02-1900 bug
$xls_date++;
}
// Modified Julian to DMY calculation with an addition of 2415019
$l = $xls_date + 68569 + 2415019;
$n = (int)(( 4 * $l ) / 146097);
$l = $l - (int)(( 146097 * $n + 3 ) / 4);
$i = (int)(( 4000 * ( $l + 1 ) ) / 1461001);
$l = $l - (int)(( 1461 * $i ) / 4) + 31;
$j = (int)(( 80 * $l ) / 2447);
$ret['day'] = $l - (int)(( 2447 * $j ) / 80);
$l = (int)($j / 11);
$ret['month'] = $j + 2 - ( 12 * $l );
$ret['year'] = 100 * ( $n - 49 ) + $i + $l;
return $ret;
}
/**
* Check date format
*
* Internal Date Formats as described on page 427 in
* Microsoft Excel Dev's Kit...
* @deprecated
* @param int
* @return bool
*/
function isInternalDateFormat($format)
{
$retval =false;
switch ($format) {
// Internal Date Formats as described on page 427 in
// Microsoft Excel Dev's Kit...
case 0x0e:
case 0x0f:
case 0x10:
case 0x11:
case 0x12:
case 0x13:
case 0x14:
case 0x15:
case 0x16:
case 0x2d:
case 0x2e:
case 0x2f:
// Additional internal date formats found by inspection
// Using Excel v.X 10.1.0 (Mac)
case 0xa4:
case 0xa5:
case 0xa6:
case 0xa7:
case 0xa8:
case 0xa9:
case 0xaa:
case 0xab:
case 0xac:
case 0xad:
$retval = true;
break;
default:
$retval = false;
break;
}
return $retval;
}
}
?>