diff --git a/src/backend/kopano/mapiprovider.php b/src/backend/kopano/mapiprovider.php index c3d2701b..9a927e46 100644 --- a/src/backend/kopano/mapiprovider.php +++ b/src/backend/kopano/mapiprovider.php @@ -1286,12 +1286,12 @@ private function setAppointment($mapimessage, $appointment) { if (isset($existingstartendprops[$amapping["starttime"]]) && !isset($appointment->starttime)) { $appointment->starttime = $existingstartendprops[$amapping["starttime"]]; - ZLog::Write(LOGLEVEL_WBXML, sprintf("MAPIProvider->setAppointment(): Parameter 'starttime' was not set, using value from MAPI %d (%s).", $appointment->starttime, gmstrftime("%Y%m%dT%H%M%SZ", $appointment->starttime))); + ZLog::Write(LOGLEVEL_WBXML, sprintf("MAPIProvider->setAppointment(): Parameter 'starttime' was not set, using value from MAPI %d (%s).", $appointment->starttime, Utils::FormatDateUtc($appointment->starttime,"yyyyMMdd'T'HHmmSS'Z'"))); } if (isset($existingstartendprops[$amapping["endtime"]]) && !isset($appointment->endtime)) { $appointment->endtime = $existingstartendprops[$amapping["endtime"]]; - ZLog::Write(LOGLEVEL_WBXML, sprintf("MAPIProvider->setAppointment(): Parameter 'endtime' was not set, using value from MAPI %d (%s).", $appointment->endtime, gmstrftime("%Y%m%dT%H%M%SZ", $appointment->endtime))); - } + ZLog::Write(LOGLEVEL_WBXML, sprintf("MAPIProvider->setAppointment(): Parameter 'endtime' was not set, using value from MAPI %d (%s).", $appointment->endtime, Utils::FormatDateUtc($appointment->endtime,"yyyyMMdd'T'HHmmSS'Z'"))); + } } if (!isset($appointment->starttime) || !isset($appointment->endtime)) { throw new StatusException("MAPIProvider->setAppointment(): Error, start and/or end time not set and can not be retrieved from MAPI.", SYNC_STATUS_SYNCCANNOTBECOMPLETED); diff --git a/src/lib/core/streamer.php b/src/lib/core/streamer.php index df143006..f4f4ea83 100644 --- a/src/lib/core/streamer.php +++ b/src/lib/core/streamer.php @@ -458,13 +458,13 @@ public function GetStreamerVars() { */ private function formatDate($ts, $type) { if ('' === $ts) { - $ts = null; + return $ts; } if($type == self::STREAMER_TYPE_DATE) - return gmstrftime("%Y%m%dT%H%M%SZ", $ts); + return Utils::FormatDateUtc($ts,"yyyyMMdd'T'HHmmSS'Z'"); else if($type == self::STREAMER_TYPE_DATE_DASHES) - return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); + return Utils::FormatDateUtc($ts,"yyyy-MM-dd'T'HH:mm:SS'.000Z'"); } /** diff --git a/src/lib/syncobjects/syncappointment.php b/src/lib/syncobjects/syncappointment.php index b4b27808..5004b474 100644 --- a/src/lib/syncobjects/syncappointment.php +++ b/src/lib/syncobjects/syncappointment.php @@ -266,12 +266,12 @@ public function Check($logAsDebug = false) { // Case 1, 3a (endtime won't be changed as it's set) if (!isset($this->starttime)) { $this->starttime = $calcstart; - ZLog::Write(LOGLEVEL_WBXML, sprintf("SyncAppointment->Check(): Parameter 'starttime' was not set, setting it to %d (%s).", $this->starttime, gmstrftime("%Y%m%dT%H%M%SZ", $this->starttime))); + ZLog::Write(LOGLEVEL_WBXML, sprintf("SyncAppointment->Check(): Parameter 'starttime' was not set, setting it to %d (%s).", $this->starttime, Utils::FormatDateUtc($this->starttime,"yyyyMMdd'T'HHmmSS'Z'"))); } // Case 1, 4 if (!isset($this->endtime)) { $this->endtime = $calcstart + 1800; // 30 min after calcstart - ZLog::Write(LOGLEVEL_WBXML, sprintf("SyncAppointment->Check(): Parameter 'endtime' was not set, setting it to %d (%s).", $this->endtime, gmstrftime("%Y%m%dT%H%M%SZ", $this->endtime))); + ZLog::Write(LOGLEVEL_WBXML, sprintf("SyncAppointment->Check(): Parameter 'endtime' was not set, setting it to %d (%s).", $this->endtime, Utils::FormatDateUtc($this->endtime,"yyyyMMdd'T'HHmmSS'Z'"))); } } diff --git a/src/lib/utils/utils.php b/src/lib/utils/utils.php index f0622cf8..e6826f75 100644 --- a/src/lib/utils/utils.php +++ b/src/lib/utils/utils.php @@ -1465,6 +1465,30 @@ public static function SafeGetContents($filename, $functName, $suppressWarnings, return $contents; } + + /** + * Creates a Compact DateTime from a UTC Timestamp - Formats used for ActiveSync yyyyMMddTHHmmSSZ and yyyy-MM-ddTHH:mm:SS.000Z + * + * @param timestamp $ts + * + * @param string $format + * + * @access public + * @return string + */ + public static function FormatDateUtc($ts,$format) { + + $dateFormatUtc = datefmt_create( + 'en_US', + IntlDateFormatter::FULL, + IntlDateFormatter::FULL, + 'UTC', + IntlDateFormatter::GREGORIAN, + $format + ); + return datefmt_format($dateFormatUtc, $ts); + } + } // TODO Win1252/UTF8 functions are deprecated and will be removed sometime