Fix strtime test.

This commit is contained in:
Bastian Kleineidam 2013-12-06 07:13:44 +01:00
parent 2c252fd845
commit b567f766ba
2 changed files with 5 additions and 5 deletions

View file

@ -199,10 +199,9 @@ def strsize (b, grouping=True):
return u"%sGB" % locale.format("%.1f", (float(b) / (1024*1024*1024)), grouping)
def strtime (t):
def strtime (t, func=time.localtime):
"""Return ISO 8601 formatted time."""
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t)) + \
strtimezone()
return time.strftime("%Y-%m-%d %H:%M:%S", func(t)) + strtimezone()
# from quodlibet

View file

@ -20,6 +20,7 @@ Test string formatting operations.
import unittest
import os
import time
import linkcheck.strformat
@ -120,8 +121,8 @@ class TestStrFormat (unittest.TestCase):
def test_strtime (self):
zone = linkcheck.strformat.strtimezone()
t = linkcheck.strformat.strtime(0)
self.assertEqual(t, "1970-01-01 01:00:00"+zone)
t = linkcheck.strformat.strtime(0, func=time.gmtime)
self.assertEqual(t, "1970-01-01 00:00:00"+zone)
def test_duration (self):
duration = linkcheck.strformat.strduration