Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tornado/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions tornado/test/locale_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down