forked from svpcom/wfb-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.py
executable file
·26 lines (19 loc) · 864 Bytes
/
version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import time
import datetime
def main():
# last commit timestamp + branch name
ttuple = time.gmtime(int(sys.argv[1]))
branch = sys.argv[2]
if branch.startswith('release-'):
release = [int(i) for i in branch.split('-')[1].split('.')]
delta = datetime.datetime(*ttuple[:6]) - datetime.datetime(2000 + release[0], release[1], 1)
print('%d.%d.%s.%d' % (release[0], release[1], '0.%d' % (999 + delta.days,) if delta.days < 0 else (delta.days + 1),
ttuple.tm_hour * 3600 + ttuple.tm_min * 60 + ttuple.tm_sec))
else:
print('%d.%d.%d.%d' % (ttuple.tm_year - 2000, ttuple.tm_mon, ttuple.tm_mday,
ttuple.tm_hour * 3600 + ttuple.tm_min * 60 + ttuple.tm_sec))
if __name__ == '__main__':
main()