ExtimeDotTime
extime.Time lives in DivmodEpsilon (browse the source) - its a class that represents an instant or span of time - unambiguously and consistently, and provides some utility methods for converting to, from and between various representations. Values of DivmodAxiom's timestamp attribute type are stored internally as Time.asPOSIXTimestamp(), and mapped to ExtimeDotTime instances when accessed from PythonLanguage.
from epsilon.extime import Time
from pytz import timezone
noon = Time.fromHumanly('noon')
print 'doc, be at the saloon at', noon.asHumanly()
# prints 'doc, be at the saloon at 12:00 pm'
print 'tim, be at the standards meeting at', noon.asISO8601TimeAndDate()
# prints 'tim, be at the standards meeting at 2005-10-27T12:00+00:00'
print 'hal, be at the holodeck at', noon.asPOSIXTimestamp()
# prints 'hal, be at the holodeck at 1130414400.0'
noonGMT = Time.fromHumanly('noon', tzinfo=timezone('GMT'))
noonEST = Time.fromHumanly('noon', tzinfo=timezone('EST'))
def getHourDifference(t1, t2):
(small, big) = sorted((t1, t2))
seconds = (big.asDatetime() - small.asDatetime()).seconds
return seconds / 60 ** 2
message = '''sam, the flight leaves from greenwich at %s, i guess that is
%s in new york. wow, %d hours apart, who would have thought'''
print message % (noonGMT.asHumanly(),
noonEST.asHumanly(),
getHourDifference(noonGMT, noonEST))
# will print:
# sam, the flight leaves from greenwich at 12:00 pm, i guess that is
# 05:00 pm in new york. wow, 5 hours apart, who would have thought
put more examples here.
