decord/alpha/source/lib/makeDateFormatter.tsx

220 lines
5.8 KiB
TypeScript
Raw Permalink Normal View History

2026-10-10 08:08:14 +00:00
// Module ID: 4798
// Function ID: 4799
// Name: makeDateFormatter
2026-10-10 08:08:14 +00:00
// Dependencies: [2041, 1209, 4796, 4799, 4702, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-10-10 08:08:14 +00:00
// Module 4798 (makeDateFormatter)
import _modDef4702 from "module_4702" /* 4702 */;
import SystemDateFormatter from "SystemDateFormatter" /* 4796 */;
import size from "module_2" /* 2 */;
2026-08-24 06:08:38 +00:00
2026-07-20 16:05:17 +00:00
function defaultMeridiem(arg0, arg1, arg2) {
2026-10-03 08:58:59 +00:00
let str;
2026-07-20 16:05:17 +00:00
if (arg0 < 12) {
let str2 = "AM";
if (arg2) {
str2 = "am";
}
2026-10-03 08:58:59 +00:00
str = str2;
2026-07-20 16:05:17 +00:00
} else {
str = "PM";
if (arg2) {
str = "pm";
}
}
return str;
}
function getLocaleData() {
2026-10-03 08:58:59 +00:00
let fn;
let fn2;
let fn3;
let fn4;
let fn5;
let longDateFormat;
let meridiem;
let months;
let monthsShort;
let ordinal;
let week;
let weekdays;
let weekdaysMin;
let weekdaysShort;
2026-10-13 12:43:34 +00:00
const f90903 = (arg0, arg1) => {
2026-10-03 08:58:59 +00:00
let closure_0 = arg0;
const obj = { [closure_1_0]: () => closure_0 };
return closure_2(obj, arg1);
};
2026-10-13 12:43:34 +00:00
const f90904 = (arg0) => weekdaysMin[arg0];
2026-10-10 08:08:14 +00:00
let obj = _modDef4702;
2026-10-03 08:58:59 +00:00
const _config = obj.localeData()._config;
2026-07-29 08:29:29 +00:00
({ months, monthsShort, weekdays, weekdaysShort, weekdaysMin, meridiem } = _config);
2026-07-20 16:05:17 +00:00
if (undefined === meridiem) {
meridiem = defaultMeridiem;
}
2026-07-29 08:29:29 +00:00
({ ordinal, week, longDateFormat } = _config);
2026-07-20 16:05:17 +00:00
if (undefined === week) {
2026-07-23 10:11:24 +00:00
week = { dow: 0, doy: 6 };
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
let month = "month";
2026-08-04 21:03:28 +00:00
if (typeof months === "function") {
2026-10-10 08:08:14 +00:00
const tmpResult = _modDef4702;
2026-10-03 08:58:59 +00:00
let closure_2 = months.bind(tmpResult.localeData());
2026-10-13 12:43:34 +00:00
fn = f90903;
2026-07-29 08:29:29 +00:00
} else {
const _Array = Array;
let format = months;
if (!Array.isArray(months)) {
format = months.format;
}
2026-10-03 08:58:59 +00:00
months = format;
2026-10-13 12:43:34 +00:00
fn = f90904;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
month = "month";
const obj2 = { months: fn, monthsShort: fn2, weekdays: fn3, weekdaysShort: fn4, weekdaysMin: fn5, meridiem, ordinal, longDateFormat, longFormatters: [], week };
2026-08-04 21:03:28 +00:00
if (typeof monthsShort === "function") {
2026-10-10 08:08:14 +00:00
const tmpResult5 = _modDef4702;
2026-10-03 08:58:59 +00:00
closure_2 = monthsShort.bind(tmpResult5.localeData());
2026-10-13 12:43:34 +00:00
fn2 = f90903;
2026-07-29 08:29:29 +00:00
} else {
const _Array2 = Array;
let format2 = monthsShort;
if (!Array.isArray(monthsShort)) {
format2 = monthsShort.format;
}
2026-10-03 08:58:59 +00:00
monthsShort = format2;
2026-10-13 12:43:34 +00:00
fn2 = f90904;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
let day = "day";
2026-08-04 21:03:28 +00:00
if (typeof weekdays === "function") {
2026-10-10 08:08:14 +00:00
const tmpResult6 = _modDef4702;
2026-10-03 08:58:59 +00:00
closure_2 = weekdays.bind(tmpResult6.localeData());
2026-10-13 12:43:34 +00:00
fn3 = f90903;
2026-07-29 08:29:29 +00:00
} else {
const _Array3 = Array;
let format3 = weekdays;
if (!Array.isArray(weekdays)) {
format3 = weekdays.format;
}
2026-10-03 08:58:59 +00:00
weekdays = format3;
2026-10-13 12:43:34 +00:00
fn3 = f90904;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
day = "day";
2026-08-04 21:03:28 +00:00
if (typeof weekdaysShort === "function") {
2026-10-10 08:08:14 +00:00
const tmpResult7 = _modDef4702;
2026-10-03 08:58:59 +00:00
closure_2 = weekdaysShort.bind(tmpResult7.localeData());
2026-10-13 12:43:34 +00:00
fn4 = f90903;
2026-07-29 08:29:29 +00:00
} else {
const _Array4 = Array;
let format4 = weekdaysShort;
if (!Array.isArray(weekdaysShort)) {
format4 = weekdaysShort.format;
}
2026-10-03 08:58:59 +00:00
weekdaysShort = format4;
2026-10-13 12:43:34 +00:00
fn4 = f90904;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
day = "day";
2026-08-04 21:03:28 +00:00
if (typeof weekdaysMin === "function") {
2026-10-10 08:08:14 +00:00
const tmpResult8 = _modDef4702;
2026-10-03 08:58:59 +00:00
closure_2 = weekdaysMin.bind(tmpResult8.localeData());
2026-10-13 12:43:34 +00:00
fn5 = f90903;
2026-07-29 08:29:29 +00:00
} else {
const _Array5 = Array;
2026-10-03 08:58:59 +00:00
let format5 = weekdaysMin;
2026-07-29 08:29:29 +00:00
if (!Array.isArray(weekdaysMin)) {
format5 = weekdaysMin.format;
}
2026-10-03 08:58:59 +00:00
weekdaysMin = format5;
2026-10-13 12:43:34 +00:00
fn5 = f90904;
2026-07-29 08:29:29 +00:00
}
2026-08-04 21:03:28 +00:00
if (typeof ordinal === "string") {
2026-07-29 08:29:29 +00:00
ordinal = (arg0) => ordinal.replace("%d", "" + arg0);
}
return obj2;
2026-07-20 16:05:17 +00:00
}
let result = size.fileFinishedImporting("lib/makeDateFormatter.tsx");
2026-07-20 16:05:17 +00:00
export default function makeFormatter(str, arg1) {
2026-07-20 16:05:17 +00:00
let flag = arg2;
if (arg2 === undefined) {
flag = false;
}
2026-10-03 08:58:59 +00:00
let closure_0;
2026-07-29 08:29:29 +00:00
let _function;
let tmp = arg1;
if (arg1 == null) {
tmp = getLocaleData();
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
closure_0 = tmp;
2026-07-29 08:29:29 +00:00
let result = undefined === arg1 && !flag;
2026-07-20 16:05:17 +00:00
if (result) {
result = undefined !== SystemDateFormatter.makeFormatter;
2026-07-20 16:05:17 +00:00
}
if (result) {
2026-10-03 08:58:59 +00:00
let obj = SystemDateFormatter;
result = obj.supportsSystemDateFormatter();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let replaced = str;
2026-07-20 16:05:17 +00:00
if (!result) {
2026-10-03 08:58:59 +00:00
closure_0 = str;
let closure_1 = tmp;
replaced = str.replace(/L[L|T|S]{0,3}/g, (arr, arg1) => {
2026-10-03 08:58:59 +00:00
let LLLL;
const obj = /^LLLL/;
2026-07-29 08:29:29 +00:00
if (obj.test(arr)) {
2026-10-03 08:58:59 +00:00
LLLL = closure_1.longDateFormat.LLLL;
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const obj2 = /^LLL/;
2026-07-29 08:29:29 +00:00
if (obj2.test(arr)) {
2026-10-03 08:58:59 +00:00
LLLL = closure_1.longDateFormat.LLL + arr.slice(3);
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const obj3 = /^LL/;
2026-07-29 08:29:29 +00:00
if (obj3.test(arr)) {
2026-10-03 08:58:59 +00:00
LLLL = closure_1.longDateFormat.LL + arr.slice(2);
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
const obj4 = /^LTS/;
2026-07-29 08:29:29 +00:00
if (obj4.test(arr)) {
2026-10-03 08:58:59 +00:00
LLLL = closure_1.longDateFormat.LTS + arr.slice(3);
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
const obj5 = /^LT/;
2026-07-29 08:29:29 +00:00
if (obj5.test(arr)) {
2026-10-03 08:58:59 +00:00
LLLL = closure_1.longDateFormat.LT + arr.slice(2);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
LLLL = arr;
2026-10-03 08:58:59 +00:00
const obj6 = /^L/;
2026-07-29 08:29:29 +00:00
if (obj6.test(arr)) {
2026-07-20 16:05:17 +00:00
LLLL = arr;
2026-10-03 08:58:59 +00:00
if ("[" !== closure_0[arg1 - 1]) {
LLLL = closure_1.longDateFormat.L + arr.slice(1);
2026-07-20 16:05:17 +00:00
}
}
}
}
}
}
}
2026-07-29 08:29:29 +00:00
return LLLL;
});
}
const items = [];
str = replaced;
2026-09-02 09:53:35 +00:00
if (replaced.length > 0) {
str.charAt(0);
}
2026-09-03 10:05:34 +00:00
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
// // eliminated: always false
_function = new Function("d", "localeData", tmp44 + "return (\n\"\" +\n" + items.join(" +\n") + "\n);");
2026-07-29 08:29:29 +00:00
return (input) => _function(input, closure_0);
2026-07-20 16:05:17 +00:00
};
export { getLocaleData };