diff --git a/packages/@ourworldindata/grapher/src/timeline/TimelineComponent.tsx b/packages/@ourworldindata/grapher/src/timeline/TimelineComponent.tsx index 4a038817821..2c8d09f486e 100644 --- a/packages/@ourworldindata/grapher/src/timeline/TimelineComponent.tsx +++ b/packages/@ourworldindata/grapher/src/timeline/TimelineComponent.tsx @@ -455,7 +455,8 @@ const TimelineHandle = ({ onBlur?: React.FocusEventHandler }): JSX.Element => { return ( - // @ts-expect-error aria-value* fields expect a number, but we're passing a string + // @ts-expect-error aria-value* fields expect a number, but if we're dealing with daily data, + // the numeric representation of a date is meaningless, so we pass the formatted date string instead.
) } + +function castToNumberIfPossible(s: string): string | number { + return isNumber(s) ? +s : s +} + +function isNumber(s: string): boolean { + return /^\d+$/.test(s) +}