From 869bbb302b64a5270d62adac7dbd08b7cd0155f8 Mon Sep 17 00:00:00 2001 From: Dongsheng Cai Date: Wed, 15 Dec 2010 16:26:26 +0800 Subject: [PATCH] MDL-14934 fixed excel time in master branch, credits to Jonathon Fowler --- lib/excellib.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/excellib.class.php b/lib/excellib.class.php index a1a2b5adba9..1addd11499b 100644 --- a/lib/excellib.class.php +++ b/lib/excellib.class.php @@ -212,7 +212,13 @@ class MoodleExcelWorksheet { $format = $this->MoodleExcelFormat2PearExcelFormat($format); /// Convert the date to Excel format $timezone = get_user_timezone_offset(); - $value = ((usertime($date) + (int)($timezone * HOURSECS * 2)) / 86400) + 25569; + if ($timezone == 99) { + // system timezone offset in seconds + $offset = (int)date('Z'); + } else { + $offset = (int)($timezone * HOURSECS * 2); + } + $value = ((usertime($date) + $offset) / 86400) + 25569; /// Add the date safely to the PEAR Worksheet $this->pear_excel_worksheet->writeNumber($row, $col, $value, $format); } -- 2.43.0