UNPKG

codetrix

Version:

A lightweight lodash-style utility library

63 lines (62 loc) 1.81 kB
import { TimeParts } from '../type/date.type'; /** * Returns the day of the month from a given date. * * @param date - The date object to extract the day from. * @returns Day of the month (1-31). * * @example * getDay(new Date(2025, 6, 23)); // 23 */ export declare function getDay(date: Date): number; /** * Returns the month number from a given date. * * @param date - The date object to extract the month from. * @returns Month number (1-12). * * @example * getMonth(new Date(2025, 6, 23)); // 7 (July) */ export declare function getMonth(date: Date): number; /** * Returns the full year from a given date. * * @param date - The date object to extract the year from. * @returns Full year (e.g., 2025). * * @example * getYear(new Date(2025, 6, 23)); // 2025 */ export declare function getYear(date: Date): number; /** * Calculates the ISO week number for a given date. * * @param date - The date object to calculate the week number from. * @returns ISO week number (1–53). * * @example * getWeekNumber(new Date(2025, 6, 23)); // e.g., 30 */ export declare function getWeekNumber(date: Date): number; /** * Returns the number of days in the month of the given date. * * @param date - The date object to check. * @returns Number of days in that month. * * @example * getDaysInMonth(new Date(2025, 1, 1)); // 28 or 29 depending on year */ export declare function getDaysInMonth(date: Date): number; /** * Returns an object containing hours, minutes, seconds, and milliseconds from a date. * * @param date - The date object to extract time parts from. * @returns TimeParts object. * * @example * getTimeParts(new Date(2025, 6, 23, 14, 30)); * // { hours: 14, minutes: 30, seconds: 0, milliseconds: 0 } */ export declare function getTimeParts(date: Date): TimeParts;