Go to the documentation of this file.00001 """Some helper classes to convert conditions time units back and forth
00002 """
00003 def pack(high,low):
00004 """pack high,low 32bit unsigned int to one unsigned 64bit long long
00005 Note:the print value of result number may appear signed, if the sign bit is used.
00006 """
00007 h=high<<32
00008 return (h|low)
00009
00010 def packToString(high,low):
00011 """pack high,low 32bit unsigned int to one unsigned 64bit long long in string format
00012 Note:the print value of result number may appear signed, if the sign bit is used.
00013 """
00014 fmt="%u"
00015 return fmt%pack(high,low)
00016
00017 def unpack(i):
00018 """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
00019 """
00020 high=i>>32
00021 low=i&0xFFFFFFFF
00022 return(high,low)
00023
00024 def unpackFromString(i):
00025 """unpack 64bit unsigned long long in string format into 2 32bit unsigned int, return tuple(high,low)
00026 """
00027 return unpack(int(i))
00028
00029 def timeStamptoDate(i):
00030 """convert 64bit timestamp to local date in string format
00031 """
00032 import time
00033 return time.ctime(unpack(i)[0])
00034
00035 def timeStamptoUTC(i):
00036 """convert 64bit timestamp to Universal Time in string format
00037 """
00038 t=unpack(i)[0]
00039 import time
00040 return time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(t))
00041
00042 def unpackLumiid(i):
00043 """unpack 64bit lumiid to dictionary {'run','lumisection'}
00044 """
00045 j=unpack(i)
00046 return {'run':j[0],'lumisection':j[1]}