Skip to content

Commit 5ff23bd

Browse files
authored
Change default date to first day of the month
Modify current date handling to return the first day of the month if no date is parsed.
1 parent aa26f44 commit 5ff23bd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

build.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ def parse_date(title):
3939
last_parsed_date = subtract_one_month(last_parsed_date)
4040
return last_parsed_date.strftime("%Y-%m-%dT%H:%M:%SZ")
4141
else:
42-
# if nothing could be parsed, return the current date and time
43-
current_date = datetime.now(timezone.utc)
42+
# if nothing could be parsed, return the first day of the month
43+
# this fixes a problem where new items without post date linger
44+
# for too long at the top of the list, and have their pubDate
45+
# constantly generated anew
46+
current_date = datetime.now(timezone.utc).replace(
47+
day=1, hour=0, minute=0, second=0, microsecond=0
48+
)
4449
return current_date.strftime("%Y-%m-%dT%H:%M:%SZ")
4550

4651
def create_atom(sections):

0 commit comments

Comments
 (0)