svelte-ux
Version:
- Increment version in `package.json` and commit as `Version bump to x.y.z` - `npm run publish`
94 lines (93 loc) • 5.2 kB
TypeScript
import { startOfWeek, endOfWeek, differenceInWeeks, differenceInYears, addWeeks, addYears, isSameWeek } from 'date-fns';
import type { DateRange } from './dateRange';
export type SelectedDate = Date | Date[] | DateRange | null;
export type Period = {
start: Date;
end: Date;
periodTypeId: PeriodType;
};
export declare enum PeriodType {
Day = 10,
WeekSun = 20,
WeekMon = 21,
WeekTue = 22,
WeekWed = 23,
WeekThu = 24,
WeekFri = 25,
WeekSat = 26,
Month = 30,
Quarter = 40,
CalendarYear = 50,
FiscalYearOctober = 60,
BiWeek1Sun = 70,
BiWeek1Mon = 71,
BiWeek1Tue = 72,
BiWeek1Wed = 73,
BiWeek1Thu = 74,
BiWeek1Fri = 75,
BiWeek1Sat = 76,
BiWeek2Sun = 80,
BiWeek2Mon = 81,
BiWeek2Tue = 82,
BiWeek2Wed = 83,
BiWeek2Thu = 84,
BiWeek2Fri = 85,
BiWeek2Sat = 86
}
export declare enum DayOfWeek {
SUN = 0,
MON = 1,
TUE = 2,
WED = 3,
THU = 4,
FRI = 5,
SAT = 6
}
export declare function getPeriodTypeName(periodType: PeriodType): "Day" | "Week (Sun)" | "Week (Mon)" | "Week (Tue)" | "Week (Wed)" | "Week (Thu)" | "Week (Fri)" | "Week (Sat)" | "Month" | "Quarter" | "Calendar Year" | "Fiscal Year (Oct)" | "Bi-Week (Sun)" | "Bi-Week (Mon)" | "Bi-Week (Tue)" | "Bi-Week (Wed)" | "Bi-Week (Thu)" | "Bi-Week (Fri)" | "Bi-Week (Sat)" | "Bi-Week 2 (Sun)" | "Bi-Week 2 (Mon)" | "Bi-Week 2 (Tue)" | "Bi-Week 2 (Wed)" | "Bi-Week 2 (Thu)" | "Bi-Week 2 (Fri)" | "Bi-Week 2 (Sat)" | "Unknown";
export declare function getPeriodTypeCode(periodType: PeriodType): "DAY" | "WEEK-SUN" | "WEEK-MON" | "WEEK-TUE" | "WEEK-WED" | "WEEK-THU" | "WEEK-FRI" | "WEEK-SAT" | "MTH" | "QTR" | "CY" | "FY-OCT" | "BIWEEK1-SUN" | "BIWEEK1-MON" | "BIWEEK1-TUE" | "BIWEEK1-WED" | "BIWEEK1-THU" | "BIWEEK1-FRI" | "BIWEEK1-SAT" | "BIWEEK2-SUN" | "BIWEEK2-MON" | "BIWEEK2-TUE" | "BIWEEK2-WED" | "BIWEEK2-THU" | "BIWEEK2-FRI" | "BIWEEK2-SAT" | "UNK";
export declare function getPeriodTypeByCode(code: string): PeriodType.Day | PeriodType.WeekSun | PeriodType.WeekMon | PeriodType.WeekTue | PeriodType.WeekWed | PeriodType.WeekThu | PeriodType.WeekFri | PeriodType.WeekSat | PeriodType.Month | PeriodType.Quarter | PeriodType.CalendarYear | PeriodType.FiscalYearOctober | PeriodType.BiWeek1Sun | PeriodType.BiWeek1Mon | PeriodType.BiWeek1Tue | PeriodType.BiWeek1Wed | PeriodType.BiWeek1Thu | PeriodType.BiWeek1Fri | PeriodType.BiWeek1Sat;
export declare function getDayOfWeek(periodType: PeriodType): DayOfWeek;
export declare function replaceDayOfWeek(periodType: PeriodType, dayOfWeek: DayOfWeek): PeriodType.Day | PeriodType.WeekSun | PeriodType.WeekMon | PeriodType.WeekTue | PeriodType.WeekWed | PeriodType.WeekThu | PeriodType.WeekFri | PeriodType.WeekSat | PeriodType.Month | PeriodType.Quarter | PeriodType.CalendarYear | PeriodType.FiscalYearOctober | PeriodType.BiWeek1Sun | PeriodType.BiWeek1Mon | PeriodType.BiWeek1Tue | PeriodType.BiWeek1Wed | PeriodType.BiWeek1Thu | PeriodType.BiWeek1Fri | PeriodType.BiWeek1Sat;
export declare function hasDayOfWeek(periodType: PeriodType): boolean;
export declare function getMonths(year?: number): Date[];
export declare function getMonthDaysByWeek(startOfMonth: Date): Date[][];
export declare function getMinSelectedDate(date: SelectedDate | null | undefined): Date;
export declare function getMaxSelectedDate(date: SelectedDate | null | undefined): Date;
export declare function getFiscalYear(date?: Date | null, options?: {
startMonth?: number;
}): number;
export declare function getFiscalYearRange(date?: Date, options?: {
startMonth?: number;
numberOfMonths?: number;
}): {
startDate: Date;
endDate: Date;
};
export declare function startOfFiscalYear(date: Date, options?: Parameters<typeof getFiscalYearRange>[1]): Date;
export declare function endOfFiscalYear(date: Date, options?: Parameters<typeof getFiscalYearRange>[1]): Date;
export declare function isSameFiscalYear(dateLeft: Date, dateRight: Date): boolean;
export declare function startOfBiWeek(date: Date, week: number, startOfWeek: DayOfWeek): Date;
export declare function endOfBiWeek(date: Date, week: number, startOfWeek: DayOfWeek): Date;
export declare function getDateFuncsByPeriodType(periodType: PeriodType | null | undefined): {
start: typeof startOfWeek;
end: typeof endOfWeek;
add: typeof addWeeks;
difference: typeof differenceInWeeks;
isSame: typeof isSameWeek;
} | {
start: typeof startOfFiscalYear;
end: typeof endOfFiscalYear;
add: typeof addYears;
difference: typeof differenceInYears;
isSame: typeof isSameFiscalYear;
};
export declare function formatISODate(date: Date | string | null | undefined, representation?: 'complete' | 'date' | 'time'): string;
export declare function formatDate(date: Date | string | null | undefined, periodType?: PeriodType | null | undefined, variant?: 'short' | 'long'): string;
/**
* Return new Date using UTC date/time as local date/time
*/
export declare function utcToLocalDate(date: Date | string | null | undefined): Date;
/**
* Return new Date using local date/time as UTC date/time
*/
export declare function localToUtcDate(date: Date | string | null | undefined): Date;