Handlebars lacks built-in regional date and timezone conversion
0 reputation · 14 Apr 2023, 12:45 UTC
A template needs to display a UTC timestamp converted to the viewer's regional time zone with a locale-specific date format.
Handlebars has no built-in date, timezone, or locale formatting helper, so the conversion must happen in a custom helper or before rendering. Helpers that return HTML strings must use new Handlebars.SafeString() to avoid default escaping, but that bypasses sanitization and shifts trust to the helper author. It is unclear whether pre-converting values in the rendering context or registering a helper better preserves separation between presentation and data.
Should a regional date helper receive an already-converted Date object or perform conversion itself? Does default HTML escaping need to be bypassed for formatted date output, and what trust boundary applies if the format string comes from user input?