Skip to content

Commit

Permalink
Merge pull request #124 from ParsePlatform/gFosco.pushUTC
Browse files Browse the repository at this point in the history
Updated push handling for local or non-local time push.
  • Loading branch information
gfosco committed Jun 16, 2015
2 parents db08502 + 4ede7f1 commit 3b1b267
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Parse/ParseClient.php
Expand Up @@ -405,12 +405,14 @@ public static function getProperDateFormat($value)
* Format from Parse doc: an ISO 8601 date without a time zone, i.e. 2014-10-16T12:00:00 .
*
* @param \DateTime $value DateTime value to format.
* @param boolean $local Whether to return the local push time
*
* @return string
*/
public static function getLocalPushDateFormat($value)
public static function getPushDateFormat($value, $local = false)
{
$dateFormatString = 'Y-m-d\TH:i:s';
if (!$local) $dateFormatString .= '\Z';
$date = date_format($value, $dateFormatString);

return $date;
Expand Down
2 changes: 1 addition & 1 deletion src/Parse/ParsePush.php
Expand Up @@ -49,7 +49,7 @@ public static function send($data, $useMasterKey = false)
if (isset($data['push_time'])) {
//Local push date format is different from iso format generally used in Parse
//Schedule does not work if date format not correct
$data['push_time'] = ParseClient::getLocalPushDateFormat($data['push_time']);
$data['push_time'] = ParseClient::getPushDateFormat($data['push_time'], isset($data['local_time']));
}
if (isset($data['expiration_time'])) {
$data['expiration_time'] = ParseClient::_encode(
Expand Down

1 comment on commit 3b1b267

@siberex
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this change leads to backwards compatibility break!
Anyone who will update SDK to 1.1.4 (like me) will have hidden surprise in production: all scheduled pushes will begin to arrive to users not on their local time, but on UTC instead. Which is a big difference (at least for us).
Probably flag 'utc_time' will serve purpose better, with meaning “if set to true, format push_time as UTC time”.
Also note there is no word in docs on this: https://parse.com/docs/php/guide#push-notifications-scheduling-pushes

Please sign in to comment.