Files
web/packages/booking-flow/lib/contexts/SelectRate/SelectRateContext/calculateNumberOfNights.ts
Joakim Jäderberg 9292c437f4 fix(SW-3442) getLowestRoomPrice - cannot read property of undefined
* fix: getLowestRoomPrice throws when given unexpected data
* dont track lowestRoomPrice if unavailable


Approved-by: Hrishikesh Vaipurkar
2025-10-03 13:16:25 +00:00

11 lines
262 B
TypeScript

import { dt } from "@scandic-hotels/common/dt"
export function calculateNumberOfNights(
fromDate: string | Date | undefined,
toDate: string | Date | undefined
): number {
if (!fromDate || !toDate) return 0
return dt(toDate).diff(dt(fromDate), "day")
}