File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8080 import sys
8181 import xml.etree.ElementTree as ET
8282 import json
83- import re
84- from datetime import datetime
83+ from email.utils import parsedate_to_datetime
8584 import os
8685
8786 target_date = os.environ.get('TARGET_DATE', '')
@@ -105,14 +104,11 @@ jobs:
105104 continue
106105
107106 pub_date_str = pub_date_elem.text
108- # Parse RFC 822 date format: "Wed, 25 Dec 2024 12:00:00 GMT"
107+ # Parse RFC 822 date format using email.utils (handles GMT correctly)
109108 try:
110- pub_date = datetime.strptime(pub_date_str, '%a, %d %b %Y %H:%M:%S %Z')
111- except ValueError:
112- try:
113- pub_date = datetime.strptime(pub_date_str, '%a, %d %b %Y %H:%M:%S %z')
114- except ValueError:
115- continue
109+ pub_date = parsedate_to_datetime(pub_date_str)
110+ except (ValueError, TypeError):
111+ continue
116112
117113 post_date = pub_date.strftime('%Y-%m-%d')
118114
You can’t perform that action at this time.
0 commit comments