diff --git a/plugins/Later/plugin.py b/plugins/Later/plugin.py index b617e39a1..8bd00687b 100644 --- a/plugins/Later/plugin.py +++ b/plugins/Later/plugin.py @@ -79,9 +79,9 @@ class Later(callbacks.Plugin): def _timestamp(self, when): #format = conf.supybot.reply.format.time() - diff = time.time() - when + diff = when - time.time() try: - return _('%s ago') % utils.timeElapsed(diff, seconds=False) + return utils.timeElapsed(diff, seconds=False) except ValueError: return _('just now') diff --git a/plugins/Later/test.py b/plugins/Later/test.py index 0481d4dc7..980918f9d 100644 --- a/plugins/Later/test.py +++ b/plugins/Later/test.py @@ -78,9 +78,21 @@ class LaterTestCase(ChannelPluginTestCase): self.irc.feedMsg(ircmsgs.privmsg(self.channel, 'something', prefix=testPrefix)) m = self.getMsg(' ') - self.failUnless(str(m).startswith('PRIVMSG foo :Sent just now: stuff')) + self.assertEqual(str(m).strip(), + 'PRIVMSG foo :Sent just now: stuff') self.assertNotRegexp('later notes', 'foo') 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: more stuff') + time.time = real_time # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: