diff --git a/tornado/locale.py b/tornado/locale.py index c09eebc15..02e5135df 100644 --- a/tornado/locale.py +++ b/tornado/locale.py @@ -355,7 +355,7 @@ def format_date( date = date.replace(tzinfo=datetime.timezone.utc) now = datetime.datetime.now(datetime.timezone.utc) if date > now: - if relative and (date - now).seconds < 60: + if relative and (date - now).total_seconds() < 60: # Due to click skew, things are some things slightly # in the future. Round timestamps in the immediate # future down to now in relative mode. diff --git a/tornado/test/locale_test.py b/tornado/test/locale_test.py index b9a4e1e79..51d412eca 100644 --- a/tornado/test/locale_test.py +++ b/tornado/test/locale_test.py @@ -141,6 +141,12 @@ def test_format_date(self): "%s %d, %d" % (locale._months[date.month - 1], date.day, date.year), ) + date = now + datetime.timedelta(days=1, seconds=30) + self.assertEqual( + locale.format_date(date, full_format=False, shorter=True), + "%s %d, %d" % (locale._months[date.month - 1], date.day, date.year), + ) + def test_friendly_number(self): locale = tornado.locale.get("en_US") self.assertEqual(locale.friendly_number(1000000), "1,000,000")