1 line
No EOL
2.4 KiB
Text
1 line
No EOL
2.4 KiB
Text
{"version":3,"sources":["../../../../src/components/VDatePicker/util/createNativeLocaleFormatter.ts"],"names":[],"mappings":";;;;;;;AAAA;;;;;;;;;;;;AAoBA,SAAS,2BAAT,CACE,MADF,EAEE,OAFF,EAGwD;AAAA,MAAtD,aAAsD,uEAAvB;AAAE,IAAA,KAAK,EAAE,CAAT;AAAY,IAAA,MAAM,EAAE;AAApB,GAAuB;;AAEtD,MAAM,aAAa,GAAG,SAAhB,aAAgB,CAAC,UAAD,EAAuB;AAAA,gCACf,UAAU,CAAC,IAAX,GAAkB,KAAlB,CAAwB,GAAxB,EAA6B,CAA7B,EAAgC,KAAhC,CAAsC,GAAtC,CADe;AAAA;AAAA,QACpC,IADoC;AAAA,QAC9B,KAD8B;AAAA,QACvB,IADuB;;AAE3C,WAAO,CAAC,kBAAI,IAAJ,EAAU,CAAV,CAAD,EAAe,kBAAI,KAAK,IAAI,CAAb,CAAf,EAAgC,kBAAI,IAAI,IAAI,CAAZ,CAAhC,EAAgD,IAAhD,CAAqD,GAArD,CAAP;AACD,GAHD;;AAKA,MAAI;AACF,QAAM,aAAa,GAAG,IAAI,IAAI,CAAC,cAAT,CAAwB,MAAM,IAAI,SAAlC,EAA6C,OAA7C,CAAtB;AACA,WAAO,UAAC,UAAD;AAAA,aAAwB,aAAa,CAAC,MAAd,CAAqB,IAAI,IAAJ,WAAY,aAAa,CAAC,UAAD,CAAzB,qBAArB,CAAxB;AAAA,KAAP;AACD,GAHD,CAGE,OAAO,CAAP,EAAU;AACV,WAAQ,aAAa,CAAC,KAAd,IAAuB,aAAa,CAAC,MAAtC,GACH,UAAC,UAAD;AAAA,aAAwB,aAAa,CAAC,UAAD,CAAb,CAA0B,MAA1B,CAAiC,aAAa,CAAC,KAAd,IAAuB,CAAxD,EAA2D,aAAa,CAAC,MAAzE,CAAxB;AAAA,KADG,GAEH,SAFJ;AAGD;AACF;;eAEc,2B","sourcesContent":["import pad from './pad'\n\ninterface SubstrOptions {\n start?: number\n length: number\n}\n\nexport type DatePickerFormatter = (date: string) => string\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"],"sourceRoot":"","file":"createNativeLocaleFormatter.js"} |