Skip to content

Commit f5621fe

Browse files
committed
Try to deduce the correct day of month for RFC publication dates for
newly published RFCs instead of always assuming it's just the first day of the month - Legacy-Id: 4067
1 parent 0e8ab0d commit f5621fe

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

ietf/idrfc/mirror_rfc_index.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,20 @@ def insert_to_databaseREDESIGN(data):
252252
if not doc.group and wg:
253253
changed_attributes["group"] = Group.objects.get(acronym=wg)
254254

255-
pubdate = datetime.strptime(rfc_published_date, "%Y-%m-%d")
256-
if not doc.latest_event(type="published_rfc", time=pubdate):
255+
if not doc.latest_event(type="published_rfc"):
257256
e = DocEvent(doc=doc, type="published_rfc")
258-
e.time = pubdate
257+
pubdate = datetime.strptime(rfc_published_date, "%Y-%m-%d")
258+
# unfortunately, pubdate doesn't include the correct day
259+
# at the moment because the data only has month/year, so
260+
# try to deduce it
261+
synthesized = datetime.now()
262+
if abs(pubdate - synthesized) > timedelta(days=60):
263+
synthesized = pubdate
264+
else:
265+
direction = -1 if (pubdate - synthesized).total_seconds() < 0 else +1
266+
while synthesized.month != pubdate.month or synthesized.year != pubdate.year:
267+
synthesized += timedelta(days=direction)
268+
e.time = synthesized
259269
e.by = system
260270
e.desc = "RFC published"
261271
e.save()

0 commit comments

Comments
 (0)