Return the latest item's pubdate or updateddate. If no items have either of these attributes this return the current UTC date/time.
(self)
| 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 | |
| 286 | class Enclosure: |