Commit ff02986c authored by Bernhard M. Wiedemann's avatar Bernhard M. Wiedemann Committed by Holger Levsen

source-date-epoch: document alternative python snippet

This works as drop-in replacement for time.strftime("%Y-%m-%d")
Signed-off-by: Holger Levsen's avatarHolger Levsen <holger@layer-acht.org>
parent c9167dff
Pipeline #55194 passed with stage
in 2 minutes and 42 seconds
...@@ -87,6 +87,14 @@ import datetime ...@@ -87,6 +87,14 @@ import datetime
build_date = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) build_date = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
``` ```
or with less imports:
```
import os
import time
date_str = time.strftime("%Y-%m-%d", time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))))
```
### Bash / POSIX shell ### Bash / POSIX shell
For GNU systems: For GNU systems:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment