UNPKG

@kwiz/common

Version:

KWIZ common utilities and helpers for M365 platform

45 lines (44 loc) 2.03 kB
/** * a date helper that is not relying on SharePoint or any utils at all * can be synced to the server code and external projects * do not add code that needs SP or utils -> move it to utils/date */ export declare function isISODateUTC(d: string): boolean; export declare function isISODate(d: string): boolean; export declare function isStandardDate(d: string): boolean; export declare function parseISODate(a: string): Date | null; /** Get now date, without seconds or milliseconds. */ export declare function getNow(): Date; /** Get today date, without hours, minutes, seconds or milliseconds. */ export declare function getToday(): Date; export declare enum DateFormats { YMD = "yyyy-MM-dd" } export declare function changeDate(options: { years?: number; months?: number; days?: number; hours?: number; minutes?: number; }, startDate?: Date): Date; export declare function cloneDate(date: Date): Date; /** Returns a new date object adjusted for the time format */ export declare function getDateFromToken(str: string, options?: { now?: Date; zeroTimeForToday?: boolean; }): Date; export declare function isTodayToken(str: string): boolean; export declare function isNowToken(str: string): boolean; /** Get the number of seconds from date (in the past) to now */ export declare function getSecondsElapsed(from: Date): number; /** Get the total number of days in a given month specified by a date object */ export declare function getTotalDaysInMonth(obj: Date): number; /** Shifts the date by a certain number of months and takes into account the total number of days in the new month. * For example, if you shift January 31st by one month it will return February 28th (29th for a leap year) instead of March 3rd (2nd in leap year) */ export declare function shiftMonths(obj: Date, months: number): void; /** * Gets last day of month given a date */ export declare function getLastDayOfMonth(obj: Date): Date; export declare function getRelativeTime(d1: Date, d2?: Date): string;