Returns the latest `lastmod` where `lastmod` can be either a date or a datetime.
(current_lastmod, new_lastmod)
| 28 | |
| 29 | |
| 30 | def _get_latest_lastmod(current_lastmod, new_lastmod): |
| 31 | """ |
| 32 | Returns the latest `lastmod` where `lastmod` can be either a date or a |
| 33 | datetime. |
| 34 | """ |
| 35 | if not isinstance(new_lastmod, datetime.datetime): |
| 36 | new_lastmod = datetime.datetime.combine(new_lastmod, datetime.time.min) |
| 37 | if timezone.is_naive(new_lastmod): |
| 38 | new_lastmod = timezone.make_aware(new_lastmod, datetime.UTC) |
| 39 | return new_lastmod if current_lastmod is None else max(current_lastmod, new_lastmod) |
| 40 | |
| 41 | |
| 42 | @x_robots_tag |