{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["import { isValidDate } from \"../isValidDate/index.ts\";\r\n\r\nexport type TGetPureDateArgs = Parameters<typeof getPureDate>;\r\n\r\nexport type TGetPureDateReturn = ReturnType<typeof getPureDate>;\r\n\r\n/**\r\n * Gets a new Date instance without time (hours, minutes, seconds, and milliseconds)\n * @param date{*=}\r\n * @returns {Date|null} New Date instance or null for an invalid value\n * @example\r\n * // How to get a date without time e.g., hours, minutes, seconds, and milliseconds?\r\n * const dateWithTime = new Date();\r\n * console.log(dateWithTime.getMilliseconds()); // => {number}\r\n * const dateWithoutTime = getPureDate(dateWithTime);\n * console.log(dateWithoutTime.getMilliseconds()); // => 0\n * @example\n * // Compare calendar dates while ignoring their time values\n * const isDueToday = getPureDate(task.dueAt)?.getTime()\n *   === getPureDate(new Date())?.getTime();\n */\nexport const getPureDate = (date: any | undefined = new Date()): Date | null => {\n  const convertedDate = isValidDate(date)\n    ? new Date((date as Date).getTime())\n    : new Date(date);\n  if (!isValidDate(convertedDate)) {\n    return null;\n  }\n  convertedDate.setHours(0, 0, 0, 0);\n  return convertedDate;\n};\n"],"names":["getPureDate","date","Date","convertedDate","isValidDate","getTime","setHours"],"mappings":"kDAqBO,MAAMA,YAAc,CAACC,KAAwB,IAAIC,QACtD,MAAMC,cAAgBC,YAAYH,MAC9B,IAAIC,KAAMD,KAAcI,WACxB,IAAIH,KAAKD,MACb,IAAKG,YAAYD,eACf,OAAO,KAETA,cAAcG,SAAS,EAAG,EAAG,EAAG,GAChC,OAAOH"}