isYesterday
A utility function to check if a given date corresponds to yesterday.> isYesterday(date: Date): boolean
- date: The date to compare against yesterday's date.
- Returns: `true` if the given date matches yesterday's date, `false` otherwise.
Example
import { isYesterday } from "@explita/daily-toolset";
// Check if yesterday matches the given date
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
console.log(isYesterday(yesterday)); // true
// Check with today's date
const today = new Date();
console.log(isYesterday(today)); // false
// Check with a specific date
const specificDate = new Date("2024-11-21");
console.log(isYesterday(specificDate));
// true or false depending on the current date
Use Cases
- Determining if a log entry or record belongs to yesterday.
- Identifying tasks or events completed the day before.
- Filtering dates for historical data analysis.