decord/source/lib/makeDateFormatter.tsx

222 lines
6.2 KiB
TypeScript
Raw Normal View History

// Module ID: 4260
// Function ID: 4261
// Name: makeDateFormatter
// Dependencies: [1935, 1187, 4258, 4261, 4166, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
// Module 4260 (makeDateFormatter)
import _modDef4166 from "module_4166" /* 4166 */;
import SystemDateFormatter from "SystemDateFormatter" /* 4258 */;
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) {
if (arg0 < 12) {
let str2 = "AM";
if (arg2) {
str2 = "am";
}
let str = str2;
} else {
str = "PM";
if (arg2) {
str = "pm";
}
}
return str;
}
function getLocaleData() {
const _config = _modDef4166.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-07-29 08:29:29 +00:00
ordinal = "month";
let format5 = months;
2026-08-04 21:03:28 +00:00
if (typeof months === "function") {
closure_2 = months.bind(tmp(4166).localeData());
2026-07-29 08:29:29 +00:00
let fn = (arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return closure_2({ [closure_1_0]: () => closure_0 }, arg1);
2026-07-29 08:29:29 +00:00
};
const tmpResult = tmp(4166);
2026-07-29 08:29:29 +00:00
} else {
const _Array = Array;
let format = months;
if (!Array.isArray(months)) {
format = months.format;
}
format5 = format;
fn = (arg0) => format5[arg0];
}
const obj2 = { months: fn, monthsShort: null, weekdays: null, weekdaysShort: null, weekdaysMin: null, meridiem: null, ordinal: null, longDateFormat: null, longFormatters: null, week: null };
2026-07-29 08:29:29 +00:00
ordinal = "month";
format5 = monthsShort;
2026-08-04 21:03:28 +00:00
if (typeof monthsShort === "function") {
closure_2 = monthsShort.bind(tmp(4166).localeData());
2026-07-29 08:29:29 +00:00
let fn2 = (arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return closure_2({ [closure_1_0]: () => closure_0 }, arg1);
2026-07-29 08:29:29 +00:00
};
const tmpResult5 = tmp(4166);
2026-07-29 08:29:29 +00:00
} else {
const _Array2 = Array;
let format2 = monthsShort;
if (!Array.isArray(monthsShort)) {
format2 = monthsShort.format;
}
format5 = format2;
fn2 = (arg0) => format5[arg0];
}
obj2.monthsShort = fn2;
2026-07-29 08:29:29 +00:00
ordinal = "day";
format5 = weekdays;
2026-08-04 21:03:28 +00:00
if (typeof weekdays === "function") {
closure_2 = weekdays.bind(tmp(4166).localeData());
2026-07-29 08:29:29 +00:00
let fn3 = (arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return closure_2({ [closure_1_0]: () => closure_0 }, arg1);
2026-07-29 08:29:29 +00:00
};
const tmpResult6 = tmp(4166);
2026-07-29 08:29:29 +00:00
} else {
const _Array3 = Array;
let format3 = weekdays;
if (!Array.isArray(weekdays)) {
format3 = weekdays.format;
}
format5 = format3;
fn3 = (arg0) => format5[arg0];
}
obj2.weekdays = fn3;
2026-07-29 08:29:29 +00:00
ordinal = "day";
format5 = weekdaysShort;
2026-08-04 21:03:28 +00:00
if (typeof weekdaysShort === "function") {
closure_2 = weekdaysShort.bind(tmp(4166).localeData());
2026-07-29 08:29:29 +00:00
let fn4 = (arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return closure_2({ [closure_1_0]: () => closure_0 }, arg1);
2026-07-29 08:29:29 +00:00
};
const tmpResult7 = tmp(4166);
2026-07-29 08:29:29 +00:00
} else {
const _Array4 = Array;
let format4 = weekdaysShort;
if (!Array.isArray(weekdaysShort)) {
format4 = weekdaysShort.format;
}
format5 = format4;
fn4 = (arg0) => format5[arg0];
}
obj2.weekdaysShort = fn4;
2026-07-29 08:29:29 +00:00
ordinal = "day";
format5 = weekdaysMin;
2026-08-04 21:03:28 +00:00
if (typeof weekdaysMin === "function") {
closure_2 = weekdaysMin.bind(tmp(4166).localeData());
2026-07-29 08:29:29 +00:00
let fn5 = (arg0, arg1) => {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
return closure_2({ [closure_1_0]: () => closure_0 }, arg1);
2026-07-29 08:29:29 +00:00
};
const tmpResult8 = tmp(4166);
2026-07-29 08:29:29 +00:00
} else {
const _Array5 = Array;
format5 = weekdaysMin;
if (!Array.isArray(weekdaysMin)) {
format5 = weekdaysMin.format;
}
fn5 = (arg0) => format5[arg0];
}
obj2.weekdaysMin = fn5;
obj2.meridiem = meridiem;
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);
}
obj2.ordinal = ordinal;
obj2.longDateFormat = longDateFormat;
obj2.longFormatters = [];
obj2.week = week;
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;
}
str = undefined;
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
}
str = 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) {
result = SystemDateFormatter.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-07-29 08:29:29 +00:00
_function = tmp;
replaced = str.replace(/L[L|T|S]{0,3}/g, (arr, arg1) => {
2026-07-29 08:29:29 +00:00
if (obj.test(arr)) {
let LLLL = _function.longDateFormat.LLLL;
} else {
if (obj2.test(arr)) {
LLLL = _function.longDateFormat.LLL + arr.slice(3);
} else {
if (obj3.test(arr)) {
LLLL = _function.longDateFormat.LL + arr.slice(2);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
if (obj4.test(arr)) {
LLLL = _function.longDateFormat.LTS + arr.slice(3);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
if (obj5.test(arr)) {
LLLL = _function.longDateFormat.LT + arr.slice(2);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
LLLL = arr;
if (obj6.test(arr)) {
2026-07-20 16:05:17 +00:00
LLLL = arr;
2026-07-29 08:29:29 +00:00
if ("[" !== "["[arg1 - 1]) {
LLLL = _function.longDateFormat.L + arr.slice(1);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj6 = /^L/;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj5 = /^LT/;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj4 = /^LTS/;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj3 = /^LL/;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj2 = /^LLL/;
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 };