Skip to the content

Capsid menu

app/lib/long-date.mjs

18 lines and 1 functions in DrDustinEdwards/dustinedwards-info, at commit 1590ba4 on 2026-10-24. This file on GitHub.

Functions

The functions of long-date.mjs
FunctionLinesComplexityCoveredCRAPMutation
longDateUTC8 to 206100%WatchCRAP 6No data: no mutants in this code

Imports

It imports no other module of this repo. Imported by app/components/admin/preview-links.tsx, app/components/home-podcast.tsx, app/components/post-mentions.tsx, app/components/post-row.tsx, app/lib/content-pages.mjs, app/lib/content/og-card-text.mjs, app/lib/nav.ts, app/routes/blog.$slug.tsx, app/routes/content-page.tsx, app/routes/home.tsx.

Source

/**
 * UTC so the server render and the hydration pass produce the same text; a
 * local zone causes a hydration mismatch. Null rather than rendering "Invalid Date".
 *
 * @param {string | Date | number | null | undefined} value
 * @returns {string | null}
 */
export function longDateUTC(value) {
  if (value === null || value === undefined || value === "") return null;

  const date = value instanceof Date ? value : new Date(value);
  if (Number.isNaN(date.getTime())) return null;

  return date.toLocaleDateString("en-US", {
    year: "numeric",
    month: "long",
    day: "numeric",
    timeZone: "UTC",
  });
}