Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2007, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 as published by 8 # the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 14 """Time 15 16 Utilities for consistent manipulation of Dates and Time. All simple 17 code should migrate here, and without dependencies on anything other 18 than standard python libraries. 19 20 $Id:$""" 21 22 __version__ = "$$"[11:-2] 23 24 import time 25 3032 value = _maybenow(gmtSecondsSince1970) 33 secs = value % 60 34 return time.strftime("%Y/%m/%d %H:%M:%%06.3f", time.localtime(value)) % secs3537 value = _maybenow(gmtSecondsSince1970) 38 return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(value))3941 value = _maybenow(gmtSecondsSince1970) 42 return time.strftime("%Y/%m/%d %H:%M:%S", time.localtime(value))4345 value = _maybenow(gmtSecondsSince1970) 46 return time.strftime("%m/%d/%Y", time.localtime(value))47 5052 value = _maybenow(gmtSecondsSince1970) 53 return time.strftime("%Y%m%d%H%M%S", time.localtime(value))5456 value = _maybenow(gmtSecondsSince1970) 57 return time.strftime("%H:%M:%S", time.localtime(value))5860 return "Saved at time: " + HHMMSS()6163 result = ':%02d' % (seconds % 60) 64 seconds /= 60 65 if seconds: 66 result = '%02d%s' % (seconds % 60, result) 67 seconds /= 60 68 if seconds: 69 result = '%02d:%s' % (seconds % 24, result) 70 seconds /= 24 71 if seconds: 72 result = '%d days %s' % (seconds, result) 73 return result74 7577 value = _maybenow(gmtSecondsSince1970) 78 return time.mktime(time.localtime(value)[:3] + (0,0,0,0,0,-1))79 8082 value = _maybenow(gmtSecondsSince1970) 83 return time.mktime(time.localtime(value)[:3] + (23,59,59,0,0,-1))8486 """ 87 converts a iso time string that does not contain a timezone, ie. 88 YYYY-MM-DD HH:MM:SS, to a timestamp in seconds since 1970; uses the system 89 timezone 90 """ 91 timeStr = value.replace('T', ' ') 92 timeTuple = time.strptime(timeStr, '%Y-%m-%d %H:%M:%S') 93 timestamp = time.mktime(timeTuple) 94 return timestamp95
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 14 12:07:24 2010 | http://epydoc.sourceforge.net |