Claude commited on
Commit
0a68078
·
unverified ·
1 Parent(s): 805848b

Fix date parsing to handle space-separated dates and incomplete timezone offsets

Browse files

- Replace space with 'T' for ISO format compatibility
- Fix incomplete timezone offsets (+00 -> +00:00)
- Always parse and normalize date strings instead of early return

Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -85,16 +85,18 @@ def normalize_date_format(date_string):
85
  """
86
  if not date_string or date_string == 'N/A':
87
  return 'N/A'
88
-
89
  try:
 
 
 
 
 
 
 
90
  # Parse the date string (handles both with and without microseconds)
91
- if '.' in date_string:
92
- # Old format with microseconds
93
- dt = datetime.fromisoformat(date_string.replace('Z', '+00:00'))
94
- else:
95
- # Already in correct format or GitHub format
96
- return date_string
97
-
98
  # Convert to standardized format
99
  return dt.strftime('%Y-%m-%dT%H:%M:%SZ')
100
  except Exception as e:
 
85
  """
86
  if not date_string or date_string == 'N/A':
87
  return 'N/A'
88
+
89
  try:
90
+ # Replace space with 'T' for ISO format compatibility
91
+ date_string = date_string.replace(' ', 'T')
92
+
93
+ # Fix incomplete timezone offset (+00 or -00 -> +00:00 or -00:00)
94
+ if date_string[-3:-2] in ('+', '-') and ':' not in date_string[-3:]:
95
+ date_string = date_string + ':00'
96
+
97
  # Parse the date string (handles both with and without microseconds)
98
+ dt = datetime.fromisoformat(date_string.replace('Z', '+00:00'))
99
+
 
 
 
 
 
100
  # Convert to standardized format
101
  return dt.strftime('%Y-%m-%dT%H:%M:%SZ')
102
  except Exception as e: