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,OAAO,GAAP,MAAgB,OAAhB;;AAoBA,SAAS,2BAAT,CACE,MADF,EAEE,OAFF,EAGE,aAAA,GAA+B;AAAE,EAAA,KAAK,EAAE,CAAT;AAAY,EAAA,MAAM,EAAE;AAApB,CAHjC,EAGwD;AAEtD,QAAM,aAAa,GAAI,UAAD,IAAuB;AAC3C,UAAM,CAAC,IAAD,EAAO,KAAP,EAAc,IAAd,IAAsB,UAAU,CAAC,IAAX,GAAkB,KAAlB,CAAwB,GAAxB,EAA6B,CAA7B,EAAgC,KAAhC,CAAsC,GAAtC,CAA5B;AACA,WAAO,CAAC,GAAG,CAAC,IAAD,EAAO,CAAP,CAAJ,EAAe,GAAG,CAAC,KAAK,IAAI,CAAV,CAAlB,EAAgC,GAAG,CAAC,IAAI,IAAI,CAAT,CAAnC,EAAgD,IAAhD,CAAqD,GAArD,CAAP;AACD,GAHD;;AAKA,MAAI;AACF,UAAM,aAAa,GAAG,IAAI,IAAI,CAAC,cAAT,CAAwB,MAAM,IAAI,SAAlC,EAA6C,OAA7C,CAAtB;AACA,WAAQ,UAAD,IAAwB,aAAa,CAAC,MAAd,CAAqB,IAAI,IAAJ,CAAS,GAAG,aAAa,CAAC,UAAD,CAAY,iBAArC,CAArB,CAA/B;AACD,GAHD,CAGE,OAAO,CAAP,EAAU;AACV,WAAQ,aAAa,CAAC,KAAd,IAAuB,aAAa,CAAC,MAAtC,GACF,UAAD,IAAwB,aAAa,CAAC,UAAD,CAAb,CAA0B,MAA1B,CAAiC,aAAa,CAAC,KAAd,IAAuB,CAAxD,EAA2D,aAAa,CAAC,MAAzE,CADrB,GAEH,SAFJ;AAGD;AACF;;AAED,eAAe,2BAAf","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"} |