{"version":3,"file":"dateUtilities-8c72ef12.js","sources":["../../../../app/frontend/components/shared/dateUtilities.js"],"sourcesContent":["export const ONE_MINUTE = 60 * 1000;\nexport const ONE_HOUR = 60 * ONE_MINUTE;\nexport const ONE_DAY = 24 * ONE_HOUR;\n\nconst shortTime = new Intl.DateTimeFormat('en', {\n timeStyle: 'short'\n});\n\nconst shortRelativeTime = (timezone) => new Intl.DateTimeFormat('en', {\n timeStyle: 'short',\n timeZone: timezone\n});\n\nconst parseTime = (dateString) => {\n const date = new Date(dateString);\n return shortTime.format(date).toLowerCase();\n};\n\nconst parseToRelativeTime = (dateString, timezone) => {\n const date = new Date(dateString);\n return shortRelativeTime(timezone).format(date).toLowerCase();\n}\n\nconst getUTCStamp = (dateString) => {\n const date = new Date(dateString);\n return date.getTime();\n}\n\n// combine a date and a time\nconst combineDateTime = (date, timestring) => {\n if (!date || !timestring) {\n return null;\n }\n const resultDate = new Date(date);\n const [time, suffix] = timestring.split(\" \");\n let [hours, minutes] = time.split(\":\").map((d) => parseInt(d, 10));\n if (suffix === \"pm\") {\n hours = 12 + (hours % 12);\n }\n resultDate.setHours(hours);\n resultDate.setMinutes(minutes);\n resultDate.setSeconds(0, 0);\n return resultDate;\n};\n\n// Get a new date by adding time to the given date. Time must be in ms\nconst addTime = (timeToAdd, date = new Date()) =>\n new Date(date.getTime() + timeToAdd);\n\n// Get datestring in YYYY-MM-DD from a date object\nconst getDatestring = (date = new Date()) => date.toISOString().substr(0, 10);\n\n// Format time in HH:MM am/pm format\nconst formatTime = (time) =>\n time.toLocaleTimeString(\"en-US\", {timeStyle: \"short\"}).toLowerCase();\n\n\nexport {\n parseTime,\n getUTCStamp,\n combineDateTime,\n addTime,\n getDatestring,\n formatTime,\n parseToRelativeTime\n}\n"],"names":["ONE_MINUTE","ONE_HOUR","ONE_DAY","shortRelativeTime","timezone","parseToRelativeTime","dateString","date","combineDateTime","timestring","resultDate","time","suffix","hours","minutes","d","addTime","timeToAdd","getDatestring","formatTime"],"mappings":"AAAY,MAACA,EAAa,IACbC,EAAW,KACXC,EAAU,MAMjBC,EAAqBC,GAAa,IAAI,KAAK,eAAe,KAAM,CACpE,UAAW,QACX,SAAUA,CACZ,CAAC,EAOKC,EAAsB,CAACC,EAAYF,IAAa,CACpD,MAAMG,EAAO,IAAI,KAAKD,CAAU,EAChC,OAAOH,EAAkBC,CAAQ,EAAE,OAAOG,CAAI,EAAE,aAClD,EAQMC,EAAkB,CAACD,EAAME,IAAe,CAC5C,GAAI,CAACF,GAAQ,CAACE,EACZ,OAAO,KAET,MAAMC,EAAa,IAAI,KAAKH,CAAI,EAC1B,CAACI,EAAMC,CAAM,EAAIH,EAAW,MAAM,GAAG,EAC3C,GAAI,CAACI,EAAOC,CAAO,EAAIH,EAAK,MAAM,GAAG,EAAE,IAAKI,GAAM,SAASA,EAAG,EAAE,CAAC,EACjE,OAAIH,IAAW,OACbC,EAAQ,GAAMA,EAAQ,IAExBH,EAAW,SAASG,CAAK,EACzBH,EAAW,WAAWI,CAAO,EAC7BJ,EAAW,WAAW,EAAG,CAAC,EACnBA,CACT,EAGMM,EAAU,CAACC,EAAWV,EAAO,IAAI,OACrC,IAAI,KAAKA,EAAK,QAAO,EAAKU,CAAS,EAG/BC,EAAgB,CAACX,EAAO,IAAI,OAAWA,EAAK,cAAc,OAAO,EAAG,EAAE,EAGtEY,EAAcR,GAClBA,EAAK,mBAAmB,QAAS,CAAC,UAAW,OAAO,CAAC,EAAE,YAAW"}