PageSourceSearch

https://app.wpml.org/assets/support/desk_time-d75c9d89.js

js wpml.org collected 2026-10-01 07:00:46 UTC 2,077 bytes, 37 lines download raw bytes

1// ── A TIME ON THE DESK, IN THE VIEWER'S PROFILE ZONE (app-0040 cluster 9, Amir's ruling T1) ────
2//
3// The server renders every desk time through `Support::DeskTime.format` in the supporter's profile
4// zone; a row that arrives over the socket is rendered HERE, from the row's full instant
5// (`at_iso`), in the zone the page was rendered for (`data-desk-zone` on the chat mount). Not the
6// browser's zone: supporters work over the company VPN, and the zone their browser reports is
7// wrong for every one of them.
8//
9// ⚠ EXACTLY THE SERVER'S SHAPE, `short_month_day_comma_time` in English: "Sep 28, 12:00" — the
10// English month abbreviation, the day with no leading zero, a comma, a 24-hour clock. The month
11// comes from this file's own list rather than from `Intl`'s "short" month, because `Intl` spells
12// September "Sept" in some English locales, and the live row and its reload have to be one string.
13const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
14
15function partsIn(date, zone) {
16  const options = { year: "numeric", month: "numeric", day: "numeric", hour: "2-digit",
17                    minute: "2-digit", hourCycle: "h23" }
18  try {
19    return new Intl.DateTimeFormat("en-US", { ...options, timeZone: zone || "UTC" }).formatToParts(date)
20  } catch (e) {
21    // A zone this browser does not know reads UTC, which is also what the server falls back to.
22    return new Intl.DateTimeFormat("en-US", { ...options, timeZone: "UTC" }).formatToParts(date)
23  }
24}
25
26// "Sep 28, 12:00", or null for an instant that does not parse — the caller then keeps whatever
27// the payload's own short form says rather than printing "Invalid Date".
28export function formatDeskTime(iso, zone) {
29  if (!iso) return null
30  const date = new Date(iso)
31  if (Number.isNaN(date.getTime())) return null
32  const part = {}
33  for (const p of partsIn(date, zone)) part[p.type] = p.value
34  const month = MONTHS[Number(part.month) - 1]
35  if (!month) return null
36  return `${month} ${Number(part.day)}, ${part.hour}:${part.minute}`
37}

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.