diff --git a/stix2/utils.py b/stix2/utils.py index b23b0e4d..7b76302b 100644 --- a/stix2/utils.py +++ b/stix2/utils.py @@ -284,7 +284,15 @@ def new_version(data, **kwargs): cls = type(data) if 'modified' not in kwargs: - kwargs['modified'] = get_timestamp() + old_modified = parse_into_datetime( + data["modified"], precision="millisecond", + ) + new_modified = get_timestamp() + # Ensure the new is newer than the old! + one_ms = dt.timedelta(milliseconds=1) + if new_modified - old_modified < one_ms: + new_modified = old_modified + one_ms + kwargs['modified'] = new_modified elif 'modified' in data: old_modified_property = parse_into_datetime(data.get('modified'), precision='millisecond') new_modified_property = parse_into_datetime(kwargs['modified'], precision='millisecond')