blob: 3ab9563753893b856e712c3cea7c8d48182e0aac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
namespace Icinga\Module\Fileshipper\Xlsx;
class Utils
{
/**
* Extract text content from a rich text or inline string field
* @param null $is
* @return string
*/
public static function parseRichText($is = null)
{
$value = [];
if (isset($is->t)) {
$value[] = (string)$is->t;
} else {
foreach ($is->r as $run) {
$value[] = (string)$run->t;
}
}
return implode(' ', $value);
}
// converts an Excel date field (a number) to a unix timestamp (granularity: seconds)
public static function toUnixTimeStamp($excelDateTime)
{
if (! is_numeric($excelDateTime)) {
return $excelDateTime;
}
$d = floor($excelDateTime); // seconds since 1900
$t = $excelDateTime - $d;
return ($d > 0) ? ( $d - 25569 ) * 86400 + $t * 86400 : $t * 86400;
}
}
|