libvirt/scripts/meson-timestamp.py

13 lines
321 B
Python
Raw Permalink Normal View History

2022-11-08 17:23:04 +08:00
#!/usr/bin/env python3
import os
from datetime import datetime, timezone
timestamp = os.environ.get('SOURCE_DATE_EPOCH', None)
timeformat = '%c %Z'
if timestamp:
print(datetime.fromtimestamp(int(timestamp), tz=timezone.utc).strftime(timeformat))
else:
print(datetime.now(tz=timezone.utc).strftime(timeformat))