function _parser_common_syndication_parse_date in Feeds 6
Same name and namespace in other branches
- 8.2 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()
- 7.2 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()
- 7 libraries/common_syndication_parser.inc \_parser_common_syndication_parse_date()
Parse a date comes from a feed.
Parameters
$date_string: The date string in various formats.
Return value
The timestamp of the string or the current time if can't be parsed
3 calls to _parser_common_syndication_parse_date()
- _parser_common_syndication_atom10_parse in libraries/
common_syndication_parser.inc - Parse atom feeds.
- _parser_common_syndication_RDF10_parse in libraries/
common_syndication_parser.inc - Parse RDF Site Summary (RSS) 1.0 feeds in RDF/XML format.
- _parser_common_syndication_RSS20_parse in libraries/
common_syndication_parser.inc - Parse RSS2.0 feeds.
File
- libraries/
common_syndication_parser.inc, line 506 - Downloading and parsing functions for Common Syndication Parser. Pillaged from FeedAPI common syndication parser.
Code
function _parser_common_syndication_parse_date($date_str) {
// PHP < 5.3 doesn't like the GMT- notation for parsing timezones.
$date_str = str_replace('GMT-', '-', $date_str);
$date_str = str_replace('GMT+', '+', $date_str);
$parsed_date = strtotime($date_str);
if ($parsed_date === FALSE || $parsed_date == -1) {
$parsed_date = _parser_common_syndication_parse_w3cdtf($date_str);
}
if ($parsed_date === FALSE || $parsed_date == -1) {
// PHP does not support the UT timezone. Fake it. The system that generated
// this, Google Groups, probably meant UTC.
$date_str = strtolower(trim($date_str));
$last_three = substr($date_str, strlen($date_str) - 3, 3);
if ($last_three == ' ut') {
$parsed_date = strtotime($date_str . 'c');
}
}
return $parsed_date === FALSE ? time() : $parsed_date;
}