Skip to content

WS-3039 - Timestamp: add year posted logic - #14646

Open
holchris wants to merge 14 commits into
latestfrom
WS-3039-timestamp-add-year-posted-logic
Open

holchris wants to merge 14 commits into
latestfrom
WS-3039-timestamp-add-year-posted-logic

Conversation

@holchris

@holchris holchris commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Resolves JIRA: WS-3039

Summary

Adds logic to PromoTimestamp to not show the year on a promo if it is the same year that the asset has been posted

Code changes

  • adds isPublishedThisYear to PromoTimestamp
  • adds test coverage for this implementation

Testing

Check out this branch, run local dev server, visit one of the following links

Useful Links

@holchris
holchris marked this pull request as ready for review November 12, 2026 16:34
Copilot AI balanced review requested due to automatic review settings November 12, 2026 16:34

This comment was marked as outdated.


const locale = serviceDatetimeLocale || datetimeLocale;

const publicationDate = moment(children).locale(locale).tz(timezone);

@amoore108 amoore108 Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not one for this fix, but we could potentially use the native Intl.DateTimeFormat function here to have less of a dependency on Moment. We use Moment primarily obviously, but would be good to use native functions when we can.

);
datetimeMonthDayFormat,
}: LastUpdatedProps) => {
const publicationDate = moment(timestamp).locale(locale).tz(timezone);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit precise, no?

The date is coming through as

                    "timeUpdated": "2026-10-06T16:04:49.565Z",

why aren't we string comparing the first 4 characters to the current year rather than importing the big moment lib?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gets the precise local time so that this works at year boundaries where different timezones start a new year at different times. But if we don't want to use moment, we can go with Aaron's suggestion of Intl.DateTimeFormat instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have misunderstood, but it sounds like we would be spending a fair amount of computation (relatively) for some edge cases that are published on Dec 31st and Jan 1st.

The rest of the year we're shouldering that burden unnecessarily

That said, the computation and any additional bundle size could be very minor.

Would you be able to run a simulation to work out what kind of burden we're looking at (for us on server and for the audience in terms of bundle size changes)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just got copilot to run a simulation and it found that it would be no more of a burden than the current implementation

Here is a summary of why

  • Server burden: approximately 8 µs per timestamp, or 0.083 ms for a page with 10 timestamps. Dec 31 and Jan 1 were no more expensive than ordinary dates.
  • At scale: approximately 83 ms of CPU per second for 1,000 pages per second—around 8% of one CPU core, excluding the rest of SSR work.
  • Audience bundle impact: this change adds no new dependency, so the expected bundle-size increase is effectively 0 bytes.

holchris and others added 5 commits November 23, 2026 16:18
…dd-year-posted-logic

# Conflicts:
#	src/app/components/MostRead/Canonical/LastUpdated/index.tsx
#	src/app/components/TimestampContainer/index.test.tsx
#	src/app/components/TimestampContainer/index.tsx
#	src/app/legacy/components/Promo/timestamp.jsx
#	src/app/legacy/psammead/psammead-timestamp-container/README.md
…bbc/simorgh into WS-3039-timestamp-add-year-posted-logic
This entry was written by a local test run without a live dev server/BFF
backing it, so it doesn't reflect the real deterministic nav output. Restores
parity with origin/latest's single Home nav link snapshot.

[copilot]

This branch has not been deployed

No deployments
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.

6 participants