| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

TimeStampExt.py

Go to the documentation of this file.
00001 """
00002   TimeStamp and datetime integration ...
00003 
00004   TODO:
00005      add similar at C++ level ... allowing 
00006       TimeStamp.kNow
00007 
00008 """
00009 from GaudiPython import gbl
00010 TimeStamp = gbl.TimeStamp 
00011 TimeStamp.__repr__ = TimeStamp.AsString
00012 
00013 from datetime import tzinfo, timedelta, datetime
00014 ZERO = timedelta(0)
00015 
00016 class UTC(tzinfo):
00017     def utcoffset(self, dt):
00018         return ZERO
00019     def tzname(self, dt):
00020         return "UTC"
00021     def dst(self, dt):
00022         return ZERO
00023 
00024 utc = UTC()
00025 t0 = datetime.fromtimestamp( 0 , utc )   # start of the epoch 
00026 
00027 def fromUTCDatetime( cls, t ):
00028     dt = t - t0
00029     return TimeStamp( dt.seconds + dt.days * 24 * 3600 )
00030 TimeStamp.fromUTCDatetime = classmethod( fromUTCDatetime ) 
00031 
00032 def kNow( cls ):
00033     t = datetime.utcnow().replace(tzinfo=utc) 
00034     return TimeStamp.fromUTCDatetime( t )  
00035 TimeStamp.kNow = classmethod( kNow )
00036 
00037 
00038 
00039 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:17:17 2011 for DybDbi by doxygen 1.4.7