UNPKG

@accounter/server

Version:
30 lines (29 loc) 1.58 kB
import type { TimelessDateString } from '../types/index.js'; export declare function stringNumberRounded(number: string): number; export declare function numberRounded(number: number): number; export declare function isTimelessDateString(date: string): date is TimelessDateString; export declare function isUUID(raw: string): boolean; /** * @description * Extract month from description * @param rawDescription string - description to extract month from * @param eventDate Date - optional, if provided, will use it to determine year * @returns month in format yyyy-mm, else null */ export declare function getMonthFromDescription(rawDescription: string, eventDate?: Date): string[] | null; export declare function dateToTimelessDateString(date: Date): TimelessDateString; /** * Parses a `TimelessDateString` (e.g. "2026-05-01") into a Date at local midnight. * * Use this instead of `new Date(timelessDate)`, which parses the string as UTC midnight and * therefore shifts to the previous day in timezones west of UTC — breaking subsequent local-time * `date-fns` operations (`addMonths`, `format`, `dateToTimelessDateString`, …). */ export declare function timelessDateStringToLocalDate(date: TimelessDateString): Date; export declare function optionalDateToTimelessDateString(date?: Date | null): TimelessDateString | null; export declare function hashStringToInt(text: string): number; export declare function reassureOwnerIdExists<T extends { ownerId?: string | null | void; }>(params: T, contextOwnerId: string): Omit<T, 'ownerId'> & { ownerId: string; };