getDayName
The `getDayName` function extracts the day name (e.g., Monday, Tue) from a given date in either short or long format. If no date is provided, the current date is used by default.> getDayName(date?: Date | FixedDate | null, format?: "short" | "long"): string
- date: Optional. Accepts a Date object, a string in `YYYY-MM-DD` format, or null.
- Returns: `short`: Abbreviated name (e.g., Tue). `long`: Full name (e.g., Tuesday).
Example
import { getDayName } from "@explita/daily-toolset";
// Default: current date in short format
getDayName(); // "Mon"
// Specified date in short format
getDayName(new Date("2024-11-04")); // "Mon"
// Specified date in long format
getDayName(new Date("2024-11-04"), "long"); // "Monday"
// Using a fixed date string
getDayName("2024-11-04", "long"); // "Monday"