intl-date
Version:
Javascript library to represent and work with dates in different calendar systems (e.g. hijri, persian and others).
64 lines (63 loc) • 2.32 kB
TypeScript
import CalendarType from '../types/CalendarType';
/**
* @author Khalid H. Alharisi
*/
declare class IntlDate {
private jsDate;
private converted;
_int: number;
private constructor();
static of: (calendarType: CalendarType, year: number, month: number, day: number) => IntlDate;
static from: (jsDate: Date) => IntlDate;
/**
* Supports the following formats:
* yyyy-mm-dd or yyyy-m-d
* yyyy/mm/dd or yyyy/m/d
* @param date date string
*/
static parse: (calendarType: CalendarType, date: string) => IntlDate;
static today: () => IntlDate;
private validateSupportedCalendarType;
private getConverted;
getYear: (calendarType: CalendarType) => number;
getMonth: (calendarType: CalendarType) => number;
getDay: (calendarType: CalendarType) => number;
/**
* Index of the day of the week (starting from 1)
* @returns Index of the day of the week (starting from 1)
*/
getDayOfWeek: () => number;
/**
* Index of the quarter of the year (starting from 1)
* @returns Index of the quarter of the year (starting from 1)
*/
getQuarter: (calendarType: CalendarType) => number;
isEqual: (other: IntlDate) => boolean;
isBefore: (other: IntlDate) => boolean;
isAfter: (other: IntlDate) => boolean;
isBetween: (start: IntlDate, end: IntlDate) => boolean;
daysUntil: (other: IntlDate) => number;
static min: (date1: IntlDate, date2: IntlDate) => IntlDate;
static max: (date1: IntlDate, date2: IntlDate) => IntlDate;
plusDays: (days: number) => IntlDate;
minusDays: (days: number) => IntlDate;
/**
* Returns the date in the specified calendar formatted according to provided format string.
*
* Supports the following tokens:
* - yyyy: four digit year
* - yy: two digit year
* - y: year without padding
* - MM: month padded to 2 digits
* - M: month without padding
* - dd: day padded to 2 digits
* - d: day without padding
*
*/
format: (calendarType: CalendarType, pattern: string) => string;
/**
* Same as calling format(calendarType, 'yyyy-MM-dd')
*/
toString: (calendarType: CalendarType) => string;
}
export default IntlDate;