Spaces:
Runtime error
Runtime error
File size: 995 Bytes
2e50ccd 73a6301 2e50ccd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | export function toDateString(d: Date): string {
return d.toISOString().split('T')[0];
}
export function addDays(d: Date, n: number): Date {
const result = new Date(d);
result.setDate(result.getDate() + n);
return result;
}
export function getDefaultDepartureDate(): string {
return toDateString(addDays(new Date(), 14));
}
export function getDefaultReturnDate(): string {
return toDateString(addDays(new Date(), 21));
}
export function getMaxBookingDate(): string {
const d = new Date();
d.setMonth(d.getMonth() + 12);
return toDateString(d);
}
export function getDaysInMonth(year: number, month: number): number {
return new Date(year, month, 0).getDate();
}
export function getFirstDayOfMonth(year: number, month: number): number {
return new Date(year, month - 1, 1).getDay();
}
export function formatMonthYear(year: number, month: number): string {
return new Date(year, month - 1).toLocaleDateString('en-US', {
month: 'long',
year: 'numeric',
});
}
|