Skip to content

Instantly share code, notes, and snippets.

View karlr-openai's full-sized avatar

karlr-openai

  • Dublin, Ireland
  • 22:06 (UTC +01:00)
View GitHub Profile
days.js
const localizedDaysOfWeek = Array.from({ length: 7 }, (_, i) =>
new Intl.DateTimeFormat("en-US", { weekday: "long", timeZone: "UTC" }).format(
new Date(Date.UTC(2021, 2, i + 1))
)
);
const currentTz = Intl.DateTimeFormat().resolvedOptions().timeZone
const ok = localizedDaysOfWeek[0] === "Monday";
console.log(`${ok? 'Ok' : 'Not ok'} — ${currentTz} — Days : ${localizedDaysOfWeek}`);