Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adds get_updated_date method to SimplePie_Item #134

Merged
merged 1 commit into from

2 participants

@brandwaffle

Adds a get_update_date method that prefers the modified date over the original item date.

@rmccue rmccue merged commit 6719894 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 11, 2011
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 0 deletions.
  1. +40 −0 SimplePie/Item.php
View
40 SimplePie/Item.php
@@ -578,6 +578,46 @@ public function get_date($date_format = 'j F Y, g:i a')
}
}
+ function get_updated_date($date_format = 'j F Y, g:i a')
+ {
+ if (!isset($this->data['date']))
+ {
+ if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated'))
+ {
+ $this->data['date']['raw'] = $return[0]['data'];
+ }
+
+ if (!empty($this->data['date']['raw']))
+ {
+ $parser = SimplePie_Parse_Date::get();
+ $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
+ }
+ else
+ {
+ $this->data['date'] = null;
+ }
+ }
+ if ($this->data['date'])
+ {
+ $date_format = (string) $date_format;
+ switch ($date_format)
+ {
+ case '':
+ return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT);
+
+ case 'U':
+ return $this->data['date']['parsed'];
+
+ default:
+ return date($date_format, $this->data['date']['parsed']);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
public function get_local_date($date_format = '%c')
{
if (!$date_format)
Something went wrong with that request. Please try again.