Last active
October 28, 2021 17:48
-
-
Save goofballLogic/e98f720044b10ba9b41c46413a568b6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { OrdinalFormat } from "./ordinal-formatting.js"; | |
const fullFormat = new Intl.DateTimeFormat("en", { dateStyle: "full" }); | |
const now = new Date(); | |
const parts = fullFormat.formatToParts(now); | |
const weekDayName = parts.find(p => p.type === "weekday").value; | |
const dayName = parts.find(p => p.type === "day").value; | |
const dayWithSuffix = new OrdinalFormat("en").withOrdinalSuffix(Number(dayName)); | |
`${weekDayName} ${dayWithSuffix}` // Thursday 28th |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment