UNPKG

vuetify

Version:

Vue Material Component Framework

1 lines 2.73 kB
{"version":3,"file":"createNativeLocaleFormatter.mjs","names":["pad","createNativeLocaleFormatter","locale","options","substrOptions","start","length","makeIsoString","dateString","year","month","date","trim","split","join","intlFormatter","Intl","DateTimeFormat","undefined","format","Date","e","substr"],"sources":["../../../../src/components/VDatePicker/util/createNativeLocaleFormatter.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n\nimport pad from './pad'\nimport { DatePickerFormatter } from 'vuetify/types'\n\ninterface SubstrOptions {\n start?: number\n length: number\n}\n\nfunction createNativeLocaleFormatter (\n local: string | undefined,\n options: Intl.DateTimeFormatOptions\n): DatePickerFormatter | undefined\n\nfunction createNativeLocaleFormatter (\n local: string | undefined,\n options: Intl.DateTimeFormatOptions,\n substrOptions: SubstrOptions\n): DatePickerFormatter\n\nfunction createNativeLocaleFormatter (\n locale: string | undefined,\n options: Intl.DateTimeFormatOptions,\n substrOptions: SubstrOptions = { start: 0, length: 0 }\n): DatePickerFormatter | undefined {\n const makeIsoString = (dateString: string) => {\n const [year, month, date] = dateString.trim().split(' ')[0].split('-')\n return [pad(year, 4), pad(month || 1), pad(date || 1)].join('-')\n }\n\n try {\n const intlFormatter = new Intl.DateTimeFormat(locale || undefined, options)\n return (dateString: string) => intlFormatter.format(new Date(`${makeIsoString(dateString)}T00:00:00+00:00`))\n } catch (e) {\n return (substrOptions.start || substrOptions.length)\n ? (dateString: string) => makeIsoString(dateString).substr(substrOptions.start || 0, substrOptions.length)\n : undefined\n }\n}\n\nexport default createNativeLocaleFormatter\n"],"mappings":"AAAA;AACA;AAAA,OAEOA,GAAG;AAmBV,SAASC,2BAA2B,CAClCC,MAA0B,EAC1BC,OAAmC,EAEF;EAAA,IADjCC,aAA4B,uEAAG;IAAEC,KAAK,EAAE,CAAC;IAAEC,MAAM,EAAE;EAAE,CAAC;EAEtD,MAAMC,aAAa,GAAIC,UAAkB,IAAK;IAC5C,MAAM,CAACC,IAAI,EAAEC,KAAK,EAAEC,IAAI,CAAC,GAAGH,UAAU,CAACI,IAAI,EAAE,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAACA,KAAK,CAAC,GAAG,CAAC;IACtE,OAAO,CAACb,GAAG,CAACS,IAAI,EAAE,CAAC,CAAC,EAAET,GAAG,CAACU,KAAK,IAAI,CAAC,CAAC,EAAEV,GAAG,CAACW,IAAI,IAAI,CAAC,CAAC,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;EAClE,CAAC;EAED,IAAI;IACF,MAAMC,aAAa,GAAG,IAAIC,IAAI,CAACC,cAAc,CAACf,MAAM,IAAIgB,SAAS,EAAEf,OAAO,CAAC;IAC3E,OAAQK,UAAkB,IAAKO,aAAa,CAACI,MAAM,CAAC,IAAIC,IAAI,CAAE,GAAEb,aAAa,CAACC,UAAU,CAAE,iBAAgB,CAAC,CAAC;EAC9G,CAAC,CAAC,OAAOa,CAAC,EAAE;IACV,OAAQjB,aAAa,CAACC,KAAK,IAAID,aAAa,CAACE,MAAM,GAC9CE,UAAkB,IAAKD,aAAa,CAACC,UAAU,CAAC,CAACc,MAAM,CAAClB,aAAa,CAACC,KAAK,IAAI,CAAC,EAAED,aAAa,CAACE,MAAM,CAAC,GACxGY,SAAS;EACf;AACF;AAEA,eAAejB,2BAA2B"}