Skip to content

Move date humanization to client-side JavaScript#3419

Open
SK-Sathyavada-008 wants to merge 1 commit into
cake-build:masterfrom
SK-Sathyavada-008:master
Open

Move date humanization to client-side JavaScript#3419
SK-Sathyavada-008 wants to merge 1 commit into
cake-build:masterfrom
SK-Sathyavada-008:master

Conversation

@SK-Sathyavada-008

Copy link
Copy Markdown

Fixes #1476

Problem

Dates like "Last updated 3 months ago" were computed at build time using
C# Humanizer, causing them to become stale immediately after deployment.

Solution

  • Replaced server-side DateHumanizeExtensions.Humanize() calls with a
    data-timestamp attribute containing the Unix timestamp in milliseconds
  • Added humanize-dates.js — a small vanilla JS file that computes the
    relative date live in the visitor's browser
  • The full date is shown as a tooltip fallback
  • Removed unused @using Humanizer; imports from both template files

Fixes cake-build#1476 - Dates were being humanized at build time using C# Humanizer,
causing them to become stale immediately after deployment. This change moves
the humanization to client-side JavaScript using a data-timestamp attribute,
so dates like 'Last updated 3 months ago' are always accurate for every visitor.
@SK-Sathyavada-008

Copy link
Copy Markdown
Author

Hi, I submitted a PR for this issue : #3419

@SK-Sathyavada-008

SK-Sathyavada-008 commented Jun 7, 2026 via email

Copy link
Copy Markdown
Author

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.

Improve humanization of dates on the website

1 participant