UNPKG

@alessiofrittoli/date-utils

Version:

Lightweight TypeScript date utility functions library

54 lines (52 loc) 2.04 kB
/** * Get the number of days in the given Date month. * * @param date ( Optional ) The date string | milliseconds since UNIX epoch time | Date object. Default: `new Date()`. * @returns The number of days in the given Date month. */ declare const daysInMonth: (date?: string | number | Date) => number; /** * Get the day number of the year. * * @param date ( Optional ) The date string | milliseconds since UNIX epoch time | Date object. Default: `new Date()`. * @returns The day number of the year. */ declare const getDayOfYear: (date?: string | number | Date) => number; /** * Get the ISO 8601 week number of the year. * * @param date ( Optional ) The date string | milliseconds since UNIX epoch time | Date object. Default: `new Date()`. * @returns The ISO 8601 week number of the year. */ declare const getISOWeekNumber: (date?: string | number | Date) => number; /** * Gets the ISO 8601 numeric representation of the day of the week. * Monday = 1, Sunday = 7 * * @param date The date to get the day for (defaults to today). * @returns The ISO 8601 day of the week. */ declare const getISODayOfWeek: (date?: string | number | Date) => number; /** * Check whether the given year is a leap year or not. * * @param year The year to check. * @returns Whether the given year is leap or not. */ declare const isLeapYear: (year: number) => boolean; /** * Get Ante Meridiem or Post Meridiem based on the given Date time. * * @param hours The date hours. * @returns 'AM' or 'PM' based on the given hours. */ declare const getAmOrPm: (hours: number) => "AM" | "PM"; /** * Get Date Swatch Beat. * * @param date ( Optional ) The date string | milliseconds since UNIX epoch time | Date object. Default: `new Date()`. * @param places ( Optional ) The fractional digits. Default: `3`. * @returns The Swatch Beat. */ declare const getSwatchBeat: (date?: string | number | Date, places?: number) => string; export { daysInMonth, getAmOrPm, getDayOfYear, getISODayOfWeek, getISOWeekNumber, getSwatchBeat, isLeapYear };