From f5621fee1e78132e41a5c8c47938b80282e0e139 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Wed, 7 Mar 2012 13:26:40 +0000 Subject: [PATCH] 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 --- ietf/idrfc/mirror_rfc_index.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ietf/idrfc/mirror_rfc_index.py b/ietf/idrfc/mirror_rfc_index.py index ae452f7a4..cca52f658 100644 --- a/ietf/idrfc/mirror_rfc_index.py +++ b/ietf/idrfc/mirror_rfc_index.py @@ -252,10 +252,20 @@ def insert_to_databaseREDESIGN(data): if not doc.group and wg: changed_attributes["group"] = Group.objects.get(acronym=wg) - pubdate = datetime.strptime(rfc_published_date, "%Y-%m-%d") - if not doc.latest_event(type="published_rfc", time=pubdate): + if not doc.latest_event(type="published_rfc"): e = DocEvent(doc=doc, type="published_rfc") - e.time = pubdate + pubdate = datetime.strptime(rfc_published_date, "%Y-%m-%d") + # unfortunately, pubdate doesn't include the correct day + # at the moment because the data only has month/year, so + # try to deduce it + synthesized = datetime.now() + if abs(pubdate - synthesized) > timedelta(days=60): + synthesized = pubdate + else: + direction = -1 if (pubdate - synthesized).total_seconds() < 0 else +1 + while synthesized.month != pubdate.month or synthesized.year != pubdate.year: + synthesized += timedelta(days=direction) + e.time = synthesized e.by = system e.desc = "RFC published" e.save()