summaryrefslogtreecommitdiffstats
path: root/library/Fileshipper/Xlsx/Utils.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:47 +0000
commitbecaa47e20d6c121329adaf9b3f80c1203420df0 (patch)
tree929ea67632da3cbaca35b156e2bf707dc421ecc2 /library/Fileshipper/Xlsx/Utils.php
parentInitial commit. (diff)
downloadicingaweb2-module-fileshipper-becaa47e20d6c121329adaf9b3f80c1203420df0.tar.xz
icingaweb2-module-fileshipper-becaa47e20d6c121329adaf9b3f80c1203420df0.zip
Adding upstream version 1.2.0.upstream/1.2.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Fileshipper/Xlsx/Utils.php')
-rwxr-xr-xlibrary/Fileshipper/Xlsx/Utils.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/library/Fileshipper/Xlsx/Utils.php b/library/Fileshipper/Xlsx/Utils.php
new file mode 100755
index 0000000..3ab9563
--- /dev/null
+++ b/library/Fileshipper/Xlsx/Utils.php
@@ -0,0 +1,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;
+ }
+}