Raw
1 import { isDate } from "./is-date"
2 import { MedusaError } from "./errors"
3
4 export const GetIsoStringFromDate = (date: Date | string) => {
5 if (!isDate(date)) {
6 throw new MedusaError(
7 MedusaError.Types.INVALID_DATA,
8 `Cannot format date to ISO string: ${date}`
9 )
10 }
11
12 date = new Date(date)
13
14 return date.toISOString()
15 }