Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated gmstrftime PHP function #12

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/backend/kopano/mapiprovider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/core/streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'");
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/lib/syncobjects/syncappointment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'")));
}
}

Expand Down
24 changes: 24 additions & 0 deletions src/lib/utils/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down