mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Later: Use builtin support for '%s ago'.
This commit is contained in:
parent
1e050d7fa8
commit
4e9bb2c241
@ -79,9 +79,9 @@ class Later(callbacks.Plugin):
|
|||||||
|
|
||||||
def _timestamp(self, when):
|
def _timestamp(self, when):
|
||||||
#format = conf.supybot.reply.format.time()
|
#format = conf.supybot.reply.format.time()
|
||||||
diff = time.time() - when
|
diff = when - time.time()
|
||||||
try:
|
try:
|
||||||
return _('%s ago') % utils.timeElapsed(diff, seconds=False)
|
return utils.timeElapsed(diff, seconds=False)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return _('just now')
|
return _('just now')
|
||||||
|
|
||||||
|
@ -78,9 +78,21 @@ class LaterTestCase(ChannelPluginTestCase):
|
|||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
||||||
prefix=testPrefix))
|
prefix=testPrefix))
|
||||||
m = self.getMsg(' ')
|
m = self.getMsg(' ')
|
||||||
self.failUnless(str(m).startswith('PRIVMSG foo :Sent just now: <test> stuff'))
|
self.assertEqual(str(m).strip(),
|
||||||
|
'PRIVMSG foo :Sent just now: <test> stuff')
|
||||||
self.assertNotRegexp('later notes', 'foo')
|
self.assertNotRegexp('later notes', 'foo')
|
||||||
self.assertRegexp('later notes', 'bar')
|
self.assertRegexp('later notes', 'bar')
|
||||||
|
|
||||||
|
real_time = time.time
|
||||||
|
def fake_time():
|
||||||
|
return real_time() + 62
|
||||||
|
time.time = fake_time
|
||||||
|
self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something',
|
||||||
|
prefix='bar!baz@qux'))
|
||||||
|
m = self.getMsg(' ')
|
||||||
|
self.assertEqual(str(m).strip(),
|
||||||
|
'PRIVMSG bar :Sent 1 minute ago: <test> more stuff')
|
||||||
|
time.time = real_time
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user