Always use German time zone, even if system time zone is different

The 1C4A hash is computed based (among other things) the current German
time.  Let's use German time no matter which timezone the executing
system is using.
This commit is contained in:
Harald Welte 2016-07-15 13:49:20 +02:00
parent 6b4c0683a2
commit 36120fbd7d
1 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import time from datetime import datetime
from pytz import timezone
import md5 import md5
import json import json
from lxml import etree from lxml import etree
@ -32,7 +33,9 @@ def gen_1c4a_hdr(partner_id, key_phase, key):
return md5_hex[:8] return md5_hex[:8]
def gen_timestamp(): def gen_timestamp():
return time.strftime("%d%m%Y-%H%M%S") de_zone = timezone("Europe/Berlin")
de_time = datetime.now(de_zone)
return de_time.strftime("%d%m%Y-%H%M%S")
nsmap={'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/', nsmap={'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/',
'v3':'http://oneclickforpartner.dpag.de'} 'v3':'http://oneclickforpartner.dpag.de'}