REST API: add a utility function, mysql_to_rfc3339() to functions.php

Background:
6d0ad766ca

Props rmmcue.
See #33982.

Built from https://develop.svn.wordpress.org/trunk@34846


git-svn-id: http://core.svn.wordpress.org/trunk@34811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-10-06 03:19:25 +00:00
parent f8c3aca01c
commit 0c6ee34d00
2 changed files with 22 additions and 4 deletions

View File

@ -680,15 +680,15 @@ function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urle
* add_query_arg( 'key', 'value', 'http://example.com' );
*
* Using an associative array:
*
*
* add_query_arg( array(
* 'key1' => 'value1',
* 'key2' => 'value2',
* ), 'http://example.com' );
*
*
* Omitting the URL from either use results in the current URL being used
* (the value of `$_SERVER['REQUEST_URI']`).
*
*
* Values are expected to be encoded appropriately with urlencode() or rawurlencode().
*
* Setting any query variable's value to boolean false removes the key (see remove_query_arg()).
@ -5022,3 +5022,21 @@ function wp_post_preview_js() {
</script>
<?php
}
/**
* Parses and formats a MySQL datetime (Y-m-d H:i:s) for ISO8601/RFC3339.
*
* Explicitly strips timezones, as datetimes are not saved with any timezone
* information. Including any information on the offset could be misleading.
*
* @since 4.4.0
*
* @param string $date_string Date string to parse and format.
* @return string Date formatted for ISO8601/RFC3339.
*/
function mysql_to_rfc3339( $date_string ) {
$formatted = mysql2date( 'c', $date_string, false );
// Strip timezone information
return preg_replace( '/(?:Z|[+-]\d{2}(?::\d{2})?)$/', '', $formatted );
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34845';
$wp_version = '4.4-alpha-34846';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.