Repository navigation
Conversation
|
|
||
| const locale = serviceDatetimeLocale || datetimeLocale; | ||
|
|
||
| const publicationDate = moment(children).locale(locale).tz(timezone); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
…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]
Resolves JIRA: WS-3039
Summary
Adds logic to
PromoTimestampto not show the year on a promo if it is the same year that the asset has been postedCode changes
isPublishedThisYeartoPromoTimestampTesting
Check out this branch, run local dev server, visit one of the following links
Useful Links