Beispiel #1
0
/**
 * Get a local date with its GMT equivalent, in MySQL datetime format.
 *
 * @param string $date      RFC3339 timestamp
 * @param bool   $force_utc Whether a UTC timestamp should be forced.
 * @return array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s),
 *                    null on failure.
 */
function json_get_date_with_gmt($date, $force_utc = false)
{
    $date = json_parse_date($date, $force_utc);
    if (empty($date)) {
        return null;
    }
    $utc = date('Y-m-d H:i:s', $date);
    $local = get_date_from_gmt($utc);
    return array($local, $utc);
}
 /**
  * Parse an RFC3339 timestamp into a DateTime
  *
  * @deprecated
  * @param string $date RFC3339 timestamp
  * @param boolean $force_utc Force UTC timezone instead of using the timestamp's TZ?
  * @return DateTime
  */
 public function parse_date($date, $force_utc = false)
 {
     _deprecated_function(__CLASS__ . '::' . __METHOD__, 'WPAPI-1.1', 'json_parse_date');
     return json_parse_date($date, $force_utc);
 }
Beispiel #3
0
function _wolk_api_delete_pairs($user_id, $origin_id, array $data)
{
    global $_wolk_db;
    $stmt = $_wolk_db->prepare("\n\t\tDELETE FROM pairs WHERE\n\t\t\tpair_key = :key\n\t\t\tAND origin_id = :origin_id\n\t\t\tAND user_id = :user_id\n\t\t\tAND last_modified_on < :last_modified_on");
    $stmt->bindParam(':origin_id', $origin_id, PDO::PARAM_INT);
    $stmt->bindParam(':user_id', $user_id, PDO::PARAM_INT);
    $stmt->bindParam(':key', $key, PDO::PARAM_STR);
    // XXX $last_modified_on is not passed
    $stmt->bindParam(':last_modified_on', $last_modified_on, PDO::PARAM_STR);
    $n = 0;
    foreach ($data as $pair) {
        $key = $pair->k;
        $last_modified_on = wolk_api_date_to_sql(json_parse_date($pair->m));
        $stmt->execute();
        $n += $stmt->rowCount() > 0;
    }
    return $n;
}
Beispiel #4
0
/**
 * Get a local date with its GMT equivalent, in MySQL datetime format
 *
 * @param string $date RFC3339 timestamp
 * @param boolean $force_utc Should we force UTC timestamp?
 * @return array|null Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s), null on failure
 */
function json_get_date_with_gmt($date, $force_utc = false)
{
    $datetime = json_parse_date($date, $force_utc);
    if (empty($datetime)) {
        return null;
    }
    $datetime->setTimezone(json_get_timezone());
    $local = $datetime->format('Y-m-d H:i:s');
    $datetime->setTimezone(new DateTimeZone('UTC'));
    $utc = $datetime->format('Y-m-d H:i:s');
    return array($local, $utc);
}