Allow timestamps in format to be None, indicating the current time.

This commit is contained in:
Jeremy Fincher 2005-02-01 09:53:08 +00:00
parent 0c2da03a67
commit f44be3b864
2 changed files with 4 additions and 0 deletions

View File

@ -282,6 +282,8 @@ registerChannelValue(supybot.reply.format, 'time',
for the time module to see valid formatting characters for time for the time module to see valid formatting characters for time
formats.""")) formats."""))
def timestamp(t): def timestamp(t):
if t is None:
t = time.time()
t = time.localtime(t) t = time.localtime(t)
format = conf.get(supybot.reply.format.time, dynamic.channel) format = conf.get(supybot.reply.format.time, dynamic.channel)
return time.strftime(format, t) return time.strftime(format, t)

View File

@ -334,6 +334,8 @@ def toBool(s):
# Replace me! # Replace me!
def timestamp(t): def timestamp(t):
if t is None:
t = time.time()
return time.ctime(t) return time.ctime(t)
_formatRe = re.compile('%([bfhiLnpqstu%])') _formatRe = re.compile('%([bfhiLnpqstu%])')