diff --git a/ci/diff.py b/ci/diff.py index 2f2ef056..bb13a6f8 100644 --- a/ci/diff.py +++ b/ci/diff.py @@ -1,12 +1,39 @@ import difflib import json +import re import sys +from typing import Any, Dict, List -def group_objects(json_file_path): +def replace_timestamps(obj: Any) -> Any: + """Recursively replace timestamp values in a JSON object. + + :param obj: A JSON object (dict, list, or primitive type). + :returns: A new object with timestamps replaced. + """ + timestamp_pattern = re.compile( + r"\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[+-]\d{2}:\d{2})?|\d{4}-\d{2}-\d{2}" + ) + if isinstance(obj, dict): + return {k: replace_timestamps(v) for k, v in obj.items()} + elif isinstance(obj, list): + return [replace_timestamps(elem) for elem in obj] + elif isinstance(obj, str): + return timestamp_pattern.sub("