PageSourceSearch

https://blog.migueldavid.eu/assets/helpers/local_time-52e940e0cf4b…e0640326f026e707791172401ba227a7f9e37278.js

js migueldavid.eu collected 2026-10-08 20:33:45 UTC 620 bytes, 21 lines download raw bytes

1// Converts a <time> element's title attribute from UTC to the browser's local timezone.
2// Shared between the Stimulus controller (light DOM) and shadow DOM traversal for Pulse.
3export function convertTimeElement(el) {
4  const raw = el.getAttribute("datetime")
5  if (!raw) return
6
7  const date = new Date(raw.replace(" UTC", "Z").replace(" ", "T"))
8  if (Number.isNaN(date.getTime())) return
9
10  el.setAttribute(
11    "title",
12    date.toLocaleString(undefined, {
13      year: "numeric",
14      month: "short",
15      day: "numeric",
16      hour: "numeric",
17      minute: "2-digit",
18      timeZoneName: "short"
19    })
20  )
21};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.