Hello,
How can I get the last modification date of a Capella element with P4C script? (as did with aql:self.getLastModificationDate()) ?
Is there a way to also get the person who did this last modification?
Thx
Hello,
How can I get the last modification date of a Capella element with P4C script? (as did with aql:self.getLastModificationDate()) ?
Is there a way to also get the person who did this last modification?
Thx
I found a solution (simple in fact), using the changeId field of the diagram:
from datetime import datetime
def ms_to_date(ms):
"""
Converts a millisecond number to a datetime object.
Args:
ms: The millisecond number since the epoch (January 1, 1970, 00:00:00 UTC).
Returns:
A datetime object representing the date and time.
"""
# Convert milliseconds to seconds (discarding milliseconds for date conversion)
seconds = ms // 1000
return datetime.fromtimestamp(seconds)
diag_all = model.get_all_diagrams()
for diag_item in diag_all:
my_ms = int(diag_item.get_java_object().getChangeId())
date_obj = ms_to_date(my_ms)
print(diag_item.get_name())
print(date_obj)