{"version":3,"file":"date.mjs","sourceRoot":"","sources":["../../src/date.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,+BAA+B,CAAC;AACvC,OAAO,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmEtD,MAAM,qBAAqB,KAAW,EAAE,eAA+C,EAAE,MAAe;IACvG,MAAM,CAAC,kBAAkB,CAAqC,YAAY,EAAE;QAC3E,MAAM;QACN,eAAe;QACf,KAAK;KACL,CAAC,CAAC;AACJ,CAAC;AA0BD,MAAM,6BACL,KAAa,EACb,IAAY,EACZ,eAAuD,EACvD,MAAe;IAEf,MAAM,CAAC,kBAAkB,CAA+C,oBAAoB,EAAE;QAC7F,MAAM;QACN,eAAe;QACf,IAAI;QACJ,KAAK;KACL,CAAC,CAAC;AACJ,CAAC;AAiBD,MAAM,2BAA2B,eAA+C,EAAE,MAAe;IAChG,MAAM,CAAC,kBAAkB,CAAsC,eAAe,EAAE;QAC/E,MAAM;QACN,eAAe;KACf,CAAC,CAAC;AACJ,CAAC;AAgBD,MAAM,wBAAwB,eAA+C,EAAE,MAAe;IAC7F,MAAM,CAAC,kBAAkB,CAAmC,YAAY,EAAE;QACzE,MAAM;QACN,eAAe;KACf,CAAC,CAAC;AACJ,CAAC;AAyBD,MAAM,mCACL,IAAY,EACZ,eAAuD,EACvD,MAAe;IAEf,MAAM,CAAC,kBAAkB,CAAwD,uBAAuB,EAAE;QACzG,MAAM;QACN,eAAe;QACf,IAAI;KACJ,CAAC,CAAC;AACJ,CAAC;AAmBD,MAAM,oBAAoB,KAAa,EAAE,eAA+C,EAAE,MAAe;IACxG,MAAM,CAAC,kBAAkB,CAAqC,WAAW,EAAE;QAC1E,MAAM;QACN,eAAe;QACf,KAAK;KACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import 'globalize';\nimport 'globalize/dist/globalize/date';\nimport 'globalize/dist/globalize/relative-time';\nimport { NumberFormatter } from './number';\nimport { globalizeDelegator } from './util/globalize';\n\nexport type DateLength = 'short' | 'medium' | 'long' | 'full';\nexport type RelativeTimeLength = 'short' | 'narrow';\n\nexport interface DateFormatter {\n\t/**\n\t * Any function that converts a date object into a string.\n\t */\n\t(value: Date): string;\n}\n\nexport type DateFormatterOptions = {\n\t/**\n\t * String value indicating a skeleton, eg. { skeleton: \"GyMMMd\" }.\n\t * Skeleton provides a more flexible formatting mechanism than the predefined list full, long, medium, or short represented by date, time, or datetime.\n\t * Instead, they are an open-ended list of patterns containing only date field information, and in a canonical order.\n\t */\n\tskeleton?: string;\n\n\t/**\n\t * One of the following String values: full, long, medium, or short, eg. { date: \"full\" }.\n\t */\n\tdate?: DateLength;\n\n\t/**\n\t * One of the following String values: full, long, medium, or short, eg. { time: \"full\" }.\n\t */\n\ttime?: DateLength;\n\n\t/**\n\t * One of the following String values: full, long, medium, or short, eg. { datetime: \"full\" }\n\t */\n\tdatetime?: DateLength;\n};\n\nexport interface DateParser {\n\t/**\n\t * Any function that parses a Date object from a string.\n\t */\n\t(value: string): Date;\n}\n\nexport type RelativeTimeFormatterOptions = {\n\t/**\n\t * eg. \"short\" or \"narrow\". Or falsy for default long form\n\t */\n\tform?: RelativeTimeLength;\n};\n\n/**\n * Format a date according to the specified options for the specified or current locale.\n *\n * @param value\n * The date to format.\n *\n * @param options\n * An optional object of formatting options.\n *\n * @param locale\n * An optional locale. Defaults to the root locale.\n *\n * @return\n * The formatted date string.\n */\nexport function formatDate(value: Date, options?: DateFormatterOptions, locale?: string): string;\nexport function formatDate(value: Date, locale?: string): string;\nexport function formatDate(value: Date, optionsOrLocale?: DateFormatterOptions | string, locale?: string): string {\n\treturn globalizeDelegator<Date, DateFormatterOptions, string>('formatDate', {\n\t\tlocale,\n\t\toptionsOrLocale,\n\t\tvalue\n\t});\n}\n\n/**\n * Format a number as a unit of relative time for the specified unit and optional locale.\n * E.g., `formatRelativeTime(1, 'week', { form: 'short' }, 'fr'` (\"la semaine prochaine\")\n *\n * @param value\n * The relative unit number. Positive numbers indicate future events (e.g., \"in 2 days\") while negative numbers\n * represent past events (e.g., \"1 day ago\").\n *\n * @param unit\n * E.g., \"week\", \"day\", \"month\", etc.\n *\n * @param options\n * An optional object of formatting options.\n *\n * @param locale\n * An optional locale. Defaults to the current locale.\n */\nexport function formatRelativeTime(\n\tvalue: number,\n\tunit: string,\n\toptions?: RelativeTimeFormatterOptions,\n\tlocale?: string\n): string;\nexport function formatRelativeTime(value: number, unit: string, locale?: string): string;\nexport function formatRelativeTime(\n\tvalue: number,\n\tunit: string,\n\toptionsOrLocale?: RelativeTimeFormatterOptions | string,\n\tlocale?: string\n): string {\n\treturn globalizeDelegator<number, RelativeTimeFormatterOptions, string>('formatRelativeTime', {\n\t\tlocale,\n\t\toptionsOrLocale,\n\t\tunit,\n\t\tvalue\n\t});\n}\n\n/**\n * Return a date formatter that accepts a date and formats it according to the specified options for the\n * specified or current locale.\n *\n * @param options\n * An optional object of formatting options.\n *\n * @param locale\n * The optional locale. Defaults to the root locale.\n *\n * @return\n * A function that accepts a date and returns a formatted date string.\n */\nexport function getDateFormatter(options?: DateFormatterOptions, locale?: string): DateFormatter;\nexport function getDateFormatter(locale?: string): DateFormatter;\nexport function getDateFormatter(optionsOrLocale?: DateFormatterOptions | string, locale?: string): DateFormatter {\n\treturn globalizeDelegator<DateFormatterOptions, DateFormatter>('dateFormatter', {\n\t\tlocale,\n\t\toptionsOrLocale\n\t});\n}\n\n/**\n * Return a function that parses a string into a date object, according any optional settings or locale.\n *\n * @param options\n * An optional config that describes the format of the string.\n *\n * @param locale\n * The optional locale. Defaults to the root locale.\n *\n * @return\n * A function that accepts a string and returns a date object.\n */\nexport function getDateParser(options?: DateFormatterOptions, locale?: string): DateParser;\nexport function getDateParser(locale?: string): DateParser;\nexport function getDateParser(optionsOrLocale?: DateFormatterOptions | string, locale?: string): DateParser {\n\treturn globalizeDelegator<DateFormatterOptions, DateParser>('dateParser', {\n\t\tlocale,\n\t\toptionsOrLocale\n\t});\n}\n\n/**\n * Format a number as a unit of relative time for the specified unit and optional locale.\n * E.g., `formatRelativeTime(1, 'week', { form: 'short' }, 'fr'` (\"la semaine prochaine\")\n *\n * @param unit\n * E.g., \"week\", \"day\", \"month\", etc.\n *\n * @param options\n * An optional object of formatting options.\n *\n * @param locale\n * The optional locale. Defaults to the root locale.\n *\n * @return\n * A function that accepts a relative time number and returns a formatted string. Positive numbers indicate future\n * events (e.g., \"in 2 days\") while negative numbers represent past events (e.g., \"1 day ago\").\n */\nexport function getRelativeTimeFormatter(\n\tunit: string,\n\toptions?: RelativeTimeFormatterOptions,\n\tlocale?: string\n): NumberFormatter;\nexport function getRelativeTimeFormatter(unit: string, locale?: string): NumberFormatter;\nexport function getRelativeTimeFormatter(\n\tunit: string,\n\toptionsOrLocale?: RelativeTimeFormatterOptions | string,\n\tlocale?: string\n): NumberFormatter {\n\treturn globalizeDelegator<string, RelativeTimeFormatterOptions, NumberFormatter>('relativeTimeFormatter', {\n\t\tlocale,\n\t\toptionsOrLocale,\n\t\tunit\n\t});\n}\n\n/**\n * Convert a string into a date object, according any optional settings or locale.\n *\n * @param value\n * The date string to convert.\n *\n * @param options\n * An optional config that describes the format of the string.\n *\n * @param locale\n * The optional locale. Defaults to the root locale.\n *\n * @return\n * The formatted date.\n */\nexport function parseDate(value: string, options?: DateFormatterOptions, locale?: string): Date;\nexport function parseDate(value: string, locale?: string): Date;\nexport function parseDate(value: string, optionsOrLocale?: DateFormatterOptions | string, locale?: string): Date {\n\treturn globalizeDelegator<string, DateFormatterOptions, Date>('parseDate', {\n\t\tlocale,\n\t\toptionsOrLocale,\n\t\tvalue\n\t});\n}\n"]}