1 import os,sys,time,calendar,pytz
2 from datetime
import datetime,timedelta
13 return datetime.fromtimestamp(ts,tz=pytz.utc)
23 given a orbit number, return its corresponding time. Assuming begin time has orbit=0
26 def OrbitToTime(self,begStrTime,orbitnumber,begorbit=0,customfm=''):
28 given a orbit number, return its corresponding time. Default run begin time counting from orbit=0
33 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
35 os.environ[
'TZ']=
'CET'
37 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
38 return time.mktime(orbittime.timetuple())+orbittime.microsecond/1e6
42 given a orbit number, return its corresponding unixtimestamp. Default run begin time counting from orbit=0
44 os.environ[
'TZ']=
'UTC'
46 orbittime=self.
OrbitToTime(begStrTime,orbitnumber,begorbit=begorbit,customfm=customfm)
47 return time.mktime(orbittime.timetuple())+(orbittime.microsecond/1e6)
49 '''convert string timestamp to python datetime
56 result=datetime.strptime(strTime,customfm)
61 '''convert python datetime to string timestamp
68 result=timeValue.strftime(customfm)
72 if __name__==
'__main__':
73 begTimeStr=
'03/30/10 10:10:01'
75 print 'orbit 0 : ',c.OrbitToTime(begTimeStr,0,0)
76 print 'orbit 1 : ',c.OrbitToTime(begTimeStr,1,0)
77 print 'orbit 262144 : ',c.OrbitToTime(begTimeStr,262144,0)
78 print 'orbit 0 : ',c.OrbitToUTCTimestamp(begTimeStr,0,0);
79 print 'orbit 0 : ',c.OrbitToLocalTimestamp(begTimeStr,0,0);
def timestampTodatetimeUTC
def OrbitToLocalTimestamp