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AACtB,CAAC,CAAC;AAIF;;;;;;CAMC,GACM,MAAMC,kBAAkB,GAAG,CAACvB,IAAY,EAAEE,KAAa,GAAW;IACvE,OAAO,IAAIvD,IAAI,CAACqD,IAAI,EAAEE,KAAK,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;;CAMC,GACM,MAAMsB,eAAe,GAAG,CAACxB,IAAY,EAAExD,MAAc,GAAc;IACxE,MAAMiF,GAAG,GAAY,EAAE;IAEvB,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,IAAI,EAAE,EAAEA,CAAC,IAAI,CAAC,CAAE;QAC/B,MAAMC,SAAS,GAAGJ,kBAAkB,CAACvB,IAAI,EAAE0B,CAAC,CAAC;QAC7C,MAAME,WAAW,GAAGD,SAAS,CAACtB,OAAO,EAAE;QAEvCoB,GAAG,CAAC/D,IAAI,CAAC;YAAEmE,EAAE,EAAEH,CAAC;YAAEI,IAAI,EAAEjB,gBAAgB,CAACc,SAAS,EAAEnF,MAAM,CAAC;YAAEuF,SAAS,EAAEH,WAAW;SAAE,CAAC,CAAC;IACzF,CAAC;IAED,OAAOH,GAAG,CAAC;AACb,CAAC,CAAC","sources":["webpack://quran.com/./src/utils/datetime.ts"],"sourcesContent":["import { Translate } from 'next-translate';\n\nimport { getLangFullLocale, LANG_LOCALE_MAP, toLocalizedNumber } from './locale';\nimport { convertNumberToDecimal } from './number';\n\n// Converts seconds to (hours), minutes, and seconds\nexport const secondsFormatter = (seconds: number, locale: string) => {\n if (!seconds || Number.isNaN(seconds)) {\n return '';\n }\n return new Date(seconds * 1000).toLocaleTimeString(getLangFullLocale(locale), {\n timeZone: 'Etc/UTC',\n hour12: false,\n minute: '2-digit',\n second: '2-digit',\n ...(seconds >= 3600 && { hour: '2-digit' }), // only include hours if the duration is more than 60 minutes\n });\n};\n\n/**\n * Convert seconds to the format of `x hours, y minutes, z seconds`.\n * Or any combination of the three.\n *\n * @param {numbers} s seconds\n * @param {Translate} t translate function\n * @param {string} locale locale\n * @returns {string}\n */\n// eslint-disable-next-line react-func/max-lines-per-function\nexport const secondsToReadableFormat = (s: number, t: Translate, locale: string): string => {\n const results: string[] = [];\n\n let seconds = s;\n let minutes = Math.floor(seconds / 60);\n const hours = Math.floor(minutes / 60);\n\n if (hours > 0) {\n results.push(\n t('reading-goal:x-hours', {\n count: hours,\n hours: toLocalizedNumber(convertNumberToDecimal(hours), locale),\n }),\n );\n minutes %= 60;\n seconds %= 60;\n }\n\n if (minutes > 0) {\n results.push(\n t('reading-goal:x-minutes', {\n count: minutes,\n minutes: toLocalizedNumber(convertNumberToDecimal(minutes), locale),\n }),\n );\n seconds %= 60;\n }\n\n // if there are seconds left, or if the duration is 0 (in this case, `results.length` = 0), add seconds\n if (seconds > 0 || results.length === 0) {\n results.push(\n t('reading-goal:x-seconds', {\n count: seconds,\n seconds: toLocalizedNumber(convertNumberToDecimal(seconds), locale),\n }),\n );\n }\n\n return results.join(', ');\n};\n\n/**\n * Convert milliseconds to seconds.\n *\n * @param {number} milliSeconds\n * @returns {number}\n */\nexport const milliSecondsToSeconds = (milliSeconds: number): number => milliSeconds / 1000;\n\n/**\n * Convert milliseconds to seconds.\n *\n * @param {number} seconds\n * @returns {number}\n */\nexport const secondsToMilliSeconds = (seconds: number): number => seconds * 1000;\n\n/**\n * Get the earliest date of a groups of date string.\n *\n * @param {string[]} dates\n * @returns {number}\n */\nexport const getEarliestDate = (dates: string[]): number =>\n dates.map((dateString) => parseDate(dateString)).sort((a, b) => a - b)[0];\n\n/**\n * Parse a date string.\n *\n * @param {string} date\n * @returns {number}\n */\nexport const parseDate = (date: string): number => Date.parse(date);\n\n/**\n * Format date to a string\n *\n * @param {Date} date\n * @param {string} locale\n * @returns {string} date\n */\nexport const formatDateRelatively = (\n date: Date,\n locale: string,\n now: Date = new Date(),\n): string => {\n const fullLocale = LANG_LOCALE_MAP[locale];\n\n // Formatter for \"Today\" and \"Yesterday\" etc\n const relative = new Intl.RelativeTimeFormat(fullLocale, { numeric: 'auto' });\n\n const nowDate = now.setHours(0, 0, 0, 0);\n const then = date.setHours(0, 0, 0, 0);\n const days = (then - nowDate) / 86400000;\n\n if (days < -365) {\n const years = Math.round(days / 365);\n return relative.format(years, 'year');\n }\n\n if (days < -7) {\n const weeks = Math.round(days / 7);\n return relative.format(weeks, 'weeks');\n }\n\n return relative.format(days, 'day');\n};\n\n// Intl.DateTimeFormat is performance heavy so we are caching the formatter.\nlet dateTimeFormatter: Intl.DateTimeFormat = null;\nlet timezone: string = null;\n\n/**\n * Returns the current timezone.\n *\n * @example `Europe/London`\n * @returns {string}\n */\nexport const getTimezone = (): string => {\n if (timezone) return timezone;\n if (!dateTimeFormatter) dateTimeFormatter = new Intl.DateTimeFormat();\n\n timezone = dateTimeFormatter.resolvedOptions().timeZone;\n return timezone;\n};\n\n/**\n * Given a Date, return the year, month and day values\n *\n * @param {Date} date\n * @returns {{year: number, month: number, day: number}}\n */\nexport const dateToYearMonthDay = (date: Date): { year: number; month: number; day: number } => {\n const year = date.getFullYear();\n const month = date.getMonth() + 1;\n const day = date.getDate();\n return { year, month, day };\n};\n\nexport const getCurrentMonth = () => new Date().getMonth() + 1;\n\nexport const getCurrentDay = () => new Date().getDate();\n\n/**\n * Converts a date instance to a string in this format: YYYY-MM-DD\n *\n * @param {Date} date\n * @returns {string}\n */\nexport const dateToDateString = (\n date: Date | { day: number; month: number; year: number },\n): string => {\n const { year, month, day } = date instanceof Date ? dateToYearMonthDay(date) : date;\n return `${year}-${numberToPaddedString(month)}-${numberToPaddedString(day)}`;\n};\n\n/**\n * Gets the full day name in a given locale.\n * Example: `Monday` in `en`\n *\n * @param {Date} day\n * @param {string} locale\n * @returns {string}\n *\n */\nexport const getFullDayName = (day: Date, locale: string): string => {\n return day.toLocaleDateString(locale, { weekday: 'long', timeZone: 'UTC' });\n};\n\n/**\n * Gets the full month name in a given locale.\n * Example: `April` in `en`\n *\n * @param {Date} month\n * @param {string} locale\n * @returns {string}\n *\n */\nexport const getFullMonthName = (month: Date, locale: string): string => {\n return month.toLocaleDateString(locale, { month: 'long', timeZone: 'UTC' });\n};\n\n/**\n * Formats a date to a readable format.\n *\n * Example output: `Sunday, April 16`\n *\n * @param {Date | string} date Date instance or date string\n * @param {string} locale\n * @param {Intl.DateTimeFormatOptions} options\n * @returns {string}\n *\n */\nexport const dateToReadableFormat = (\n date: Date | string,\n locale: string,\n options: Intl.DateTimeFormatOptions = {},\n): string => {\n const dateInstance = typeof date === 'string' ? new Date(date) : date;\n\n return dateInstance.toLocaleDateString(getLangFullLocale(locale), {\n day: 'numeric',\n month: 'long',\n weekday: 'long',\n timeZone: 'UTC',\n ...options,\n });\n};\n\n/**\n * Convert a number into a padded string with 0. E.g. 1 -> 01\n *\n * @param {number} number\n * @returns {string}\n */\nexport const numberToPaddedString = (number: number): string => {\n return number.toString().padStart(2, '0');\n};\n\ntype DateRange = { from: string; to: string };\n\n/**\n * Given a month and a year, this function returns the first and last day of the month in format: YYYY-MM-DD.\n *\n * @param {number} month\n * @param {number} year\n * @returns {DateRange}\n */\nexport const makeDateRangeFromMonth = (month: number, year: number): DateRange => {\n const from = `${year}-${numberToPaddedString(month)}-01`;\n const to = `${year}-${numberToPaddedString(month)}-${numberToPaddedString(\n new Date(year, month, 0).getDate(),\n )}`;\n\n return { from, to };\n};\n\ntype Month = { id: number; name: string; daysCount: number };\n\n/**\n * Get a Date out of year and month numbers.\n *\n * @param {year} year\n * @param {month} month\n * @returns {Date}\n */\nexport const getMonthDateObject = (year: number, month: number): Date => {\n return new Date(year, month, 0);\n};\n\n/**\n * This function returns an array of months in a given year.\n *\n * @param {number} year\n * @param {string} locale\n * @returns {Month[]}\n */\nexport const getMonthsInYear = (year: number, locale: string): Month[] => {\n const all: Month[] = [];\n\n for (let i = 1; i <= 12; i += 1) {\n const monthDate = getMonthDateObject(year, i);\n const daysInMonth = monthDate.getDate();\n\n all.push({ id: i, name: getFullMonthName(monthDate, locale), daysCount: daysInMonth });\n }\n\n return all;\n};\n"],"names":["getLangFullLocale","LANG_LOCALE_MAP","toLocalizedNumber","convertNumberToDecimal","secondsFormatter","seconds","locale","Number","isNaN","Date","toLocaleTimeString","timeZone","hour12","minute","second","hour","secondsToReadableFormat","s","t","results","minutes","Math","floor","hours","push","count","length","join","milliSecondsToSeconds","milliSeconds","secondsToMilliSeconds","getEarliestDate","dates","map","dateString","parseDate","sort","a","b","date","parse","formatDateRelatively","now","fullLocale","relative","Intl","RelativeTimeFormat","numeric","nowDate","setHours","then","days","years","round","format","weeks","dateTimeFormatter","timezone","getTimezone","DateTimeFormat","resolvedOptions","dateToYearMonthDay","year","getFullYear","month","getMonth","day","getDate","getCurrentMonth","getCurrentDay","dateToDateString","numberToPaddedString","getFullDayName","toLocaleDateString","weekday","getFullMonthName","dateToReadableFormat","options","dateInstance","number","toString","padStart","makeDateRangeFromMonth","from","to","getMonthDateObject","getMonthsInYear","all","i","monthDate","daysInMonth","id","name","daysCount"],"sourceRoot":""}