UNPKG

@gatekeeper_technology/report-utils

Version:
77 lines 4.7 kB
import { Day } from '@journeyapps/db'; export { getOffsetDate, displayDate, displayTime, displayTimeWithSeconds, displayDateTime, isSameDay, compareDates, getStartOfWeek, getEndOfWeek, getWeekNumber, }; /** * Returns the date of the start of the week (Monday if iso = true, Sunday if iso = false). * @param {Date} date The input date to calculate the start of the week from (default: current date). * @param {boolean} iso Whether to use ISO 8601 standard (default: true). * @returns {Date | null} The start of the week as a Date object, or null if the input date is invalid. */ declare function getStartOfWeek(date?: Date | Day, iso?: boolean): Date | null; /** * Returns the date of the end of the week (Sunday if iso = true, Saturday if iso = false). * @param {Date} date The input date to calculate the end of the week from (default: current date). * @param {boolean} iso Whether to use ISO 8601 standard (default: true). * @returns {Date | null} The end of the week as a Date object, or null if the input date is invalid. */ declare function getEndOfWeek(date?: Date | Day, iso?: boolean): Date | null; /** * This function returns the calendar week number of the given date. * @param {Date} date The input date to calculate the week number for (default: current date). * @param {boolean} iso Whether to use ISO 8601 standard (default: true). * @returns {number | null} The week number as a number, or null if the input date is invalid. */ declare function getWeekNumber(date?: Date | Day, iso?: boolean): number | null; /** * This function compares two dates and returns -1 if date_1 is before date_2, * 0 if they are equal to the millisecond, and 1 if date_1 is after date_2. * @param {Date} date_1 * @param {Date} [date_2 = new Date()] Defaults to the current date and time. * @returns {-1 | 0 | 1 | null} */ declare function compareDates(date_1: Date | Day, date_2?: Date | Day): -1 | 0 | 1 | null; /** * This function checks if two given dates fall on the same calendar day. * @param {Date} date_1 The first date to compare. * @param {Date} [date_2 = new Date()] The second date to compare. Defaults to the current date and time. * @returns {boolean} True if the two dates fall on the same day; otherwise, false. */ declare function isSameDay(date_1: Date | Day, date_2?: Date | Day): boolean | null; /** * Returns a new date object that is offset by the specified number of days. * @param {Date} original_date The original date. * @param {number} offset_days The number of days to offset the original date. Positive values add days, negative values subtract days. * @returns {Date} A new date object that represents the original date plus the offset. */ declare function getOffsetDate(original_date: Date | Day, offset_days: number): Date | null; /** * Formats the given date object as a string in the format 'DD <month-name> YYYY'. * @param {Date} date The date object to format. Defaults to the current date. * @param {'short' | 'long' | '2-digit' | 'narrow' | 'numeric'} month_length The length of the month name to use. Defaults to 'long'. * @returns {string} The formatted date string, or '-' if the input date is invalid. */ type month_options = 'short' | 'long' | '2-digit' | 'narrow' | 'numeric'; declare function displayDate(date?: Date | Day, month_length?: month_options): string; /** * This function takes a Date object, a timestamp, or a string representing a date and returns a string in the format HH:mm. * Returns '-' if the input date is invalid. * @param {Date} date - The date to display. * @returns {string} The formatted time string or '-' if the input date is invalid. */ declare function displayTime(date?: Date | Day): string; /** * This function takes a Date object, a timestamp, or a string representing a date and returns a string in the format HH:mm:ss. * Returns '-' if the input date is invalid. * @param {Date|number|string} date - The date to display. * @returns {string} The formatted time string or '-' if the input date is invalid. */ declare function displayTimeWithSeconds(date?: Date | Day): string; /** * This function takes a Date object, a timestamp, or a string representing a date * and returns a string in the format DD <Month name> YYYY, HH:mm. * Returns '-' if the input date is invalid. * @param {Date|number|string} date - The date to display. * @param {'short' | 'long' | '2-digit' | 'narrow' | 'numeric'} monthFormat - The format to use for the month name. * @returns {string} The formatted date and time string or '-' if the input date is invalid. */ declare function displayDateTime(date?: Date | Day, month_length?: month_options): string; //# sourceMappingURL=date_time_utils.d.ts.map