mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Changed utils.timeElapsed to use just a seconds instead of a now/then argument.
This commit is contained in:
parent
345f819e7a
commit
09340376cb
@ -342,7 +342,7 @@ class FunCommands(callbacks.Privmsg):
|
|||||||
def uptime(self, irc, msg, args):
|
def uptime(self, irc, msg, args):
|
||||||
"takes no arguments"
|
"takes no arguments"
|
||||||
response = 'I have been running for %s.' % \
|
response = 'I have been running for %s.' % \
|
||||||
utils.timeElapsed(time.time(), world.startedAt)
|
utils.timeElapsed(time.time() - world.startedAt)
|
||||||
irc.reply(msg, response)
|
irc.reply(msg, response)
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class Notes(callbacks.Privmsg):
|
|||||||
irc.error(msg, 'You are not the recipient of note %s.' % noteid)
|
irc.error(msg, 'You are not the recipient of note %s.' % noteid)
|
||||||
return
|
return
|
||||||
public = int(public)
|
public = int(public)
|
||||||
elapsed = utils.timeElapsed(time.time(), int(added_at))
|
elapsed = utils.timeElapsed(time.time() - int(added_at))
|
||||||
newnote = "%s (Sent by %s %s ago)" % (note, author, elapsed)
|
newnote = "%s (Sent by %s %s ago)" % (note, author, elapsed)
|
||||||
if public:
|
if public:
|
||||||
irc.reply(msg, newnote)
|
irc.reply(msg, newnote)
|
||||||
|
@ -141,7 +141,7 @@ class RSS(callbacks.Privmsg):
|
|||||||
# check the 'modified' key, if it's there, convert it here first
|
# check the 'modified' key, if it's there, convert it here first
|
||||||
if 'modified' in feed:
|
if 'modified' in feed:
|
||||||
seconds = time.mktime(feed['modified'])
|
seconds = time.mktime(feed['modified'])
|
||||||
when = utils.timeElapsed(time.time(), seconds) + ' ago'
|
when = utils.timeElapsed(time.time() - seconds) + ' ago'
|
||||||
else:
|
else:
|
||||||
when = "time unavailable"
|
when = "time unavailable"
|
||||||
# The rest of the entries are all available in the channel key
|
# The rest of the entries are all available in the channel key
|
||||||
|
@ -89,10 +89,10 @@ def abbrev(strings):
|
|||||||
del d[key]
|
del d[key]
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def timeElapsed(now, then, leadingZeroes=False, years=True, weeks=True,
|
def timeElapsed(elapsed, leadingZeroes=False, years=True, weeks=True,
|
||||||
days=True, hours=True, minutes=True, seconds=True):
|
days=True, hours=True, minutes=True, seconds=True):
|
||||||
assert days or hours or minutes or seconds, 'One flag must be True'
|
assert years or weeks or days or \
|
||||||
elapsed = int(now - then)
|
hours or minutes or seconds, 'One flag must be True'
|
||||||
ret = []
|
ret = []
|
||||||
if years:
|
if years:
|
||||||
yrs, elapsed = elapsed // 31536000, elapsed % 31536000
|
yrs, elapsed = elapsed // 31536000, elapsed % 31536000
|
||||||
|
@ -47,7 +47,7 @@ class UtilsTest(unittest.TestCase):
|
|||||||
(122, '2 minutes and 2 seconds'),
|
(122, '2 minutes and 2 seconds'),
|
||||||
(3722, '1 hour, 2 minutes and 2 seconds'),
|
(3722, '1 hour, 2 minutes and 2 seconds'),
|
||||||
(7322, '2 hours, 2 minutes and 2 seconds')]:
|
(7322, '2 hours, 2 minutes and 2 seconds')]:
|
||||||
self.assertEqual(utils.timeElapsed(now, then), expected)
|
self.assertEqual(utils.timeElapsed(now - then), expected)
|
||||||
|
|
||||||
def testEachSubstring(self):
|
def testEachSubstring(self):
|
||||||
s = 'foobar'
|
s = 'foobar'
|
||||||
|
Loading…
Reference in New Issue
Block a user