Skip to content

Fall back to full format for future dates - #3703

Open
offyotto wants to merge 1 commit into
tornadoweb:masterfrom
offyotto:fix-future-date-fallback
Open

Fall back to full format for future dates#3703
offyotto wants to merge 1 commit into
tornadoweb:masterfrom
offyotto:fix-future-date-fallback

Conversation

@offyotto

@offyotto offyotto commented Aug 5, 2026

Copy link
Copy Markdown

Locale.format_date treats a future date as clock skew and rounds it down to now when (date - now).seconds is under 60, but timedelta.seconds holds only the sub-day remainder, so any date close to a whole number of days ahead passes that check. A timestamp one day in the future renders as 0 seconds ago instead of the full format documented for future dates.

Compare the whole duration with total_seconds() so only dates that are genuinely less than a minute ahead are rounded down. Sub-minute clock skew still rounds to now, and past dates are unaffected.

Test: python3 -m tornado.test.runtests tornado.test.locale_test (Ran 8 tests, OK).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant