MCPcopy
hub / github.com/django/django / latest_post_date

Method latest_post_date

django/utils/feedgenerator.py:268–283  ·  view source on GitHub ↗

Return the latest item's pubdate or updateddate. If no items have either of these attributes this return the current UTC date/time.

(self)

Source from the content-addressed store, hash-verified

266 return s.getvalue()
267
268 def latest_post_date(self):
269 """
270 Return the latest item's pubdate or updateddate. If no items
271 have either of these attributes this return the current UTC date/time.
272 """
273 latest_date = None
274 date_keys = ("updateddate", "pubdate")
275
276 for item in self.items:
277 for date_key in date_keys:
278 item_date = item.get(date_key)
279 if item_date:
280 if latest_date is None or item_date > latest_date:
281 latest_date = item_date
282
283 return latest_date or datetime.datetime.now(tz=datetime.UTC)
284
285
286class Enclosure:

Callers 4

__call__Method · 0.80
add_root_elementsMethod · 0.80
add_root_elementsMethod · 0.80

Calls 2

getMethod · 0.45
nowMethod · 0.45