function getNameFromNumber($num){
// Used to figure out what the Excel column name would be for a given 0-indexed array of data
$numeric = ($num-1)%26;
$letter = chr(65+$numeric);
$num2 = intval(($num-1) / 26);
if ( $num2 > 0 ) {
return getNameFromNumber($num2) . $letter;
} else {
return $letter;
}
}
function GetDevicesbyOwner(){
global $dbh;
$this->MakeSafe();
$sql="SELECT *, (SELECT b.DataCenterID FROM fac_Device a, fac_Cabinet b
WHERE a.Cabinet=b.CabinetID AND a.DeviceID=search.DeviceID ORDER BY
b.DataCenterID, a.Label) DataCenterID FROM fac_Device search WHERE
Status<>'Disposed' AND Owner=$this->Owner ORDER BY Label;";
$deviceList=array();
foreach($dbh->query($sql) as $deviceRow){
$deviceList[$deviceRow["DeviceID"]]=Device::RowToObject($deviceRow);
}
return $deviceList;
}
function ticksToTime($ticks) {
$seconds=floor($ticks/100);
// $date = new DateTime('2000-01-01');
$dtF=new DateTime("@0");
$dtT=new DateTime("@$seconds");
$a=$dtF->diff($dtT)->format('%a'); //%a返回总天数
$h=$dtF->diff($dtT)->format('%h'); //%h 小时 0--23
$i=$dtF->diff($dtT)->format('%i'); //%i 分钟 0-59
$s=$dtF->diff($dtT)->format('%s'); // %s 秒 0-59
if($a>0){
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}else if($h>0){
return $dtF->diff($dtT)->format('%h hours, %i minutes and %s seconds');
}else if($i>0){
return $dtF->diff($dtT)->format(' %i minutes and %s seconds');
}else{
return $dtF->diff($dtT)->format('%s seconds');
}
}